0

当我在 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
4

1 回答 1

0

也许您在 Windows 7 机器上的 Powershell 版本正在处理您的语法错误,这与行中缺少空格有关-Finish(Get-Date)(应该是-Finish (Get-Date)) - 而 Windows 2008 R2 机器上的 Powershell 版本不处理该错误。因此,当您删除-Startand-Finish开关时,您将删除与-Finish.

它应该是:

Get-VMHost -Name "hostname.inc.com" | Get-Stat -Stat cpu.usage.average -Start (GetDate).AddDays(-1) -Finish (Get-Date) -MaxSamples 100
于 2013-11-06T04:41:17.733 回答