如何在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 50多岁生日简短祝福语
13 安徽疫情祝福语简短英语
14 农民朋友发财祝福语简短
15 对生活祝福语简短精辟
16 搬家词简短祝福语朋友
17 女神结婚快乐祝福语简短
18 文学短句祝福语大全简短