Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.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
Powershell 获取CimException:使用无参数的获取磁盘时,属性无效_Powershell_Windows Server 2012 R2_Powershell 4.0 - Fatal编程技术网

Powershell 获取CimException:使用无参数的获取磁盘时,属性无效

Powershell 获取CimException:使用无参数的获取磁盘时,属性无效,powershell,windows-server-2012-r2,powershell-4.0,Powershell,Windows Server 2012 R2,Powershell 4.0,我有一个脚本,它使用Powershell中的Get Disk命令。使用没有参数的get Disk时,我会间歇性地出现错误: $disk = Get-Disk | Where-Object { $_.Location -eq $Location } Microsoft.Management.Infrastructure.CimException: Invalid property at Microsoft.Management.Infrastructure.Internal.Operat

我有一个脚本,它使用Powershell中的Get Disk命令。使用没有参数的get Disk时,我会间歇性地出现错误:

$disk = Get-Disk | Where-Object { $_.Location -eq $Location }

Microsoft.Management.Infrastructure.CimException: Invalid property 
   at Microsoft.Management.Infrastructure.Internal.Operations.CimAsyncObserverProxyBase`1.ProcessNativeCallback(OperationCallbackProcessingContext callbackProcessingContext, T currentItem, Boolean moreResults, MiResult operationResult, String errorMessage, InstanceHandle errorDetailsHandle)
其中
$Location
是磁盘位置(类似于
PCIROOT(0)#PCI(1500)#PCI(0000)#SAS(P00T01L00)
)。从中运行此行的脚本是我们的VM配置脚本的一部分,该脚本在克隆和VMWare自定义脚本运行后运行。这个错误并不总是发生,如果我以后手动运行脚本,每次都会成功,这让我相信这是某种竞争条件。关于为什么Get Disk不能可靠工作,有什么想法吗

最终,该脚本将使用
来宾脚本管理器
插件从vRealize Orchestrator(vRO,以前的vCenter Orchestrator或vCO)启动。此详细信息可能与此无关,但此脚本仅在被此插件启动时运行失败

其他详情:

  • Powershell版本:4.0
  • 操作系统版本:Windows Server 2012 R2
  • 虚拟机监控程序:VMWare vCenter 6.0.0版构建5112533
  • vRO版本:7.2

我最终使用diskpart而不是storage cmdlet来配置磁盘,因为它可以正常工作。虽然我确实发现我们的脚本正在运行,但Windows安装仍在完成,这可能是存储cmdlet无法正常工作的原因


跟进:我确认由于Windows安装仍在完成,存储cmdlet确实无法工作。现在我知道了如何等待完成,存储cmdlet每次都可以正常工作。

我认为
get disk
从MSFT WMI类读取/设置。我的猜测是在运行
Get Disk
之前验证
winmgmt
服务是否已启动。我修改了脚本,以确保
winmgmt
正在运行,然后继续,问题仍然存在。最后,我重新编写脚本以使用diskpart vs.storage module cmdlet。如果这个问题看起来已经解决了,我会把它作为一个解决办法来发布。