【发布时间】:2011-04-27 18:21:49
【问题描述】:
我的脚本中有几行给我一个问题:
Connect-VIServer "test-vcenter.test.com" -User user -Password pass
Get-VM -Name "test-vm" | Get-Stat -Stat cpu.ready.summation -Realtime | Select-Object -First 1 value | Format-List
运行此程序时,我收到以下输出:
Operation is not valid due to the current state of the object.
At :line:0 char:0
如果在连接到 vCenter 后几秒钟运行第二行,我会收到预期的输出。我认为正在发生的事情是,在我的第二条线路开始之前,我与 vCenter 的连接尚未完成。我不确定等待的最佳方式或在完成的连接中检查什么。
【问题讨论】:
-
从未发生过这种情况。通常我会在第二个命令尝试运行之前看到与 vCenter 的连接。
标签: powershell vmware powercli