Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows -cmdlet Get-WMIOObject中的List属性_Windows_Powershell_Wmi_Get Wmiobject - Fatal编程技术网

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}