如何在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 教师闺蜜祝福语简短