如何在PowerShell中获取该服务可用的所有属性和方法?
若要显示可用于get-servicecmdlet的所有属性和方法,您需要管道传输Get-Member(别名gm)。MemberType'Property'用于显示特定的属性,例如机器名,服务名等。使用MemberType'Method'可以对对象执行特定的操作,例如,启动,停止,暂停服务等。
命令
下面的命令用于显示Get-Service的所有成员(属性,方法)。
Get-Service | Get-Member
输出结果
Name MemberType ---- ---------- Name AliasProperty RequiredServices AliasProperty Disposed Event Close Method Continue Method CreateObjRef Method Dispose Method Equals Method ExecuteCommand Method GetHashCode Method GetLifetimeService Method GetType Method InitializeLifetimeService Method Pause Method Refresh Method Start Method Stop Method WaitForStatus Method CanPauseAndContinue Property CanShutdown Property CanStop Property Container Property DependentServices Property DisplayName Property MachineName Property ServiceHandle Property ServiceName Property ServicesDependedOn Property ServiceType Property Site Property StartType Property Status Property ToString ScriptMethod
命令
仅获取属性。
Get-Service | Get-Member | where{$_.MemberType -eq "Property"}输出结果
Name MemberType ---- ---------- CanPauseAndContinue Property CanShutdown Property CanStop Property Container Property DependentServices Property DisplayName Property MachineName Property ServiceHandle Property ServiceName Property ServicesDependedOn Property ServiceType Property Site Property StartType Property Status Property
命令
仅获得方法。
输出结果
Get-Service | Get-Member | where{$_.MemberType -eq "Method"}输出结果
Name MemberType ---- ---------- Close Method Continue Method CreateObjRef Method Dispose Method Equals Method ExecuteCommand Method GetHashCode Method GetLifetimeService Method GetType Method InitializeLifetimeService Method Pause Method Refresh Method Start Method Stop Method WaitForStatus Method
热门推荐
10 初八的祝福语简短
11 新年送老师简短祝福语
12 父亲简短结婚祝福语大全
13 对司机的祝福语简短
14 预祝高尔夫的祝福语简短
15 简短的高考祝福语精选
16 歌词祝福语高级文案简短
17 前程祝福语简短暖心
18 经典祝福语简短情侣句子