Powershell 获取CimException:使用无参数的获取磁盘时,属性无效
我有一个脚本,它使用Powershell中的Get Disk命令。使用没有参数的get Disk时,我会间歇性地出现错误: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
$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
跟进:我确认由于Windows安装仍在完成,存储cmdlet确实无法工作。现在我知道了如何等待完成,存储cmdlet每次都可以正常工作。我认为
get disk
从MSFT WMI类读取/设置。我的猜测是在运行Get Disk
之前验证winmgmt
服务是否已启动。我修改了脚本,以确保winmgmt
正在运行,然后继续,问题仍然存在。最后,我重新编写脚本以使用diskpart vs.storage module cmdlet。如果这个问题看起来已经解决了,我会把它作为一个解决办法来发布。