win2008r2上的vmware powercli get-stat为空“string”

时间:2013-10-31 13:51:35

标签: powershell vmware powercli esx

当我在windows7上使用vmware powercli从ESXi获取统计信息时,它会让我做出响应 的 Wondows7 命令:PowerCLI C:\ temp>

Get-VMHost -Name "hostname.inc.com" | Get-Stat -Stat
 cpu.usage.average  -Start (Get-Date).AddDays(-1) -Finish(Get-Date) -MaxSamples 100

返回输出

MetricId                Timestamp                          Value Unit     Insta
                                                                          nce
--------                ---------                          ----- ----     -----
cpu.usage.average       31.10.2013 15:40:00                25,03 %
cpu.usage.average       31.10.2013 15:35:00                22,95 %
cpu.usage.average       31.10.2013 15:30:00                23,97 %
...

来自 的 Windows2008r2 命令:PowerCLI C:\ temp>

Get-VMHost -Name "hostname.inc.com" | Get-Stat -Stat
 cpu.usage.average  -Start (Get-Date).AddDays(-1) -Finish(Get-Date) -MaxSamples 100

返回“没有”

有趣 - 如果在windows2008r2上运行 命令:PowerCLI C:\ temp>

Get-VMHost -Name "hostname.inc.com" | Get-Stat -Stat
 cpu.usage.average  -Realtime -MaxSamples 100

它给出了回应

cpu.usage.average       10/31/2013 9:49:40 AM               9.77 %        30
cpu.usage.average       10/31/2013 9:49:20 AM               8.63 %        30
cpu.usage.average       10/31/2013 9:49:00 AM              12.05 %        30
cpu.usage.average       10/31/2013 9:48:40 AM               11.5 %        30
cpu.usage.average       10/31/2013 9:48:20 AM              14.25 %        30
cpu.usage.average       10/31/2013 9:48:00 AM              11.02 %        30
cpu.usage.average       10/31/2013 9:47:40 AM              11.77 %        30

1 个答案:

答案 0 :(得分:0)

也许你的Windows 7机顶盒上的Powershell版本正在处理语法错误,因为行-Finish(Get-Date)中的空间不足(应该是-Finish (Get-Date)) - 而Powershell版本就是Windows 2008 R2框不处理错误。因此,当您删除-Start-Finish个开关时,您将删除与-Finish相关的语法错误。

应该是:

Get-VMHost -Name "hostname.inc.com" | Get-Stat -Stat cpu.usage.average -Start (GetDate).AddDays(-1) -Finish (Get-Date) -MaxSamples 100