如何在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 婆婆高寿祝福语大全简短