Windows -cmdlet Get-WMIOObject中的List属性
我知道Windows -cmdlet Get-WMIOObject中的List属性,windows,powershell,wmi,get-wmiobject,Windows,Powershell,Wmi,Get Wmiobject,我知道-List获取WMI存储库命名空间中的WMI类的名称,但我不太理解它在以下上下文中的含义: (Get-WmiObject -list Win32_ShadowCopy).Create("C:\","ClientAcessible") 注意:CIM cmdlet已经取代了WMI cmdlet,但是的答案在某种程度上类似于,除了获取CimInstance不支持-List,但是有一个专用的Get-CimClasscmdlet,调用类方法的最简单方法是始终使用专用的invoke-cimcmeth
-List
获取WMI存储库命名空间中的WMI类的名称,但我不太理解它在以下上下文中的含义:
(Get-WmiObject -list Win32_ShadowCopy).Create("C:\","ClientAcessible")
注意:CIM cmdlet已经取代了WMI cmdlet,但是的答案在某种程度上类似于,除了获取CimInstance
不支持-List
,但是有一个专用的Get-CimClass
cmdlet,调用类方法的最简单方法是始终使用专用的invoke-cimcmethod
cmdlet
使用
-List
参数访问Win32\u ShadowCopy
类,以便通过其.Create()
方法实例化它,该方法需要参数
相比之下,许多WMI类的实例不需要参数,因此一个简单的Get WmiObject
调用通常就足够了;e、 g:
Get-WmiObject Win32_ComputerSystem # no arguments needed; returns instance directly
指出获取WMI类的一种更简单(更快)的方法是将其名称强制转换为类型accelerator[wmiclass]
,因此基于-List
的命令的等价物是:
([wmiclass] Win32_ShadowCopy).Create("C:\","ClientAcessible")
Invoke-WmiMethod Win32_ShadowCopy -Name Create -ArgumentList "C:\", "ClientAcessible"
也就是说,在WMI类上调用方法的更像PowerShell的方法是使用调用WmiMethod
。同样,基于-List
的命令的等效项是:
([wmiclass] Win32_ShadowCopy).Create("C:\","ClientAcessible")
Invoke-WmiMethod Win32_ShadowCopy -Name Create -ArgumentList "C:\", "ClientAcessible"
对于
-列表
参数的一般用途:
让我们询问PowerShell自己的帮助系统,该系统也可用:
“谢谢,”安斯加维彻斯说。我在答案中加上了你的提示。
PS> Get-WmiObject -List -Class *shadow*
NameSpace: ROOT\cimv2
Name Methods Properties
---- ------- ----------
Win32_ShadowProvider {} {Caption, CLSID, Description, ID...}
Win32_ShadowCopy {Create, Revert} {Caption, ClientAccessible, Count, Description...}
Win32_ShadowContext {} {Caption, ClientAccessible, Description, Differential...}
Win32_ShadowStorage {Create} {AllocatedSpace, DiffVolume, MaxSpace, UsedSpace...}
Win32_ShadowVolumeSupport {} {Antecedent, Dependent}
Win32_ShadowFor {} {Antecedent, Dependent}
Win32_ShadowOn {} {Antecedent, Dependent}
Win32_ShadowBy {} {Antecedent, Dependent}
Win32_ShadowDiffVolumeSupport {} {Antecedent, Dependent}