Thanks very helful.
Ihave coxpied ur script in notepad and connect one of the esxi server and tried to run that script but getting below error
PowerCLI C:\temp> .\vm.ps1 > test.txt
Get-Stat : 9/11/2014 7:53:26 PM Get-Stat The metric counter "cpu.usag
e.average" doesn't exist for entity "Windows Test VM - old".
At C:\temp\vm.ps1:9 char:11
+ &{Get-Stat <<<< -Entity $vms -Start $start -Stat $stat |
+ CategoryInfo : ResourceUnavailable: (cpu.usage.average:String)
[Get-Stat], VimException
+ FullyQualifiedErrorId : Client20_RuntimeDataServiceImpl_CheckUserMetrics
_MetricDoesntExist,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetViStats
Get-Stat : 9/11/2014 7:53:26 PM Get-Stat The metric counter "mem.usag
e.average" doesn't exist for entity "Windows Test VM - old".
At C:\temp\vm.ps1:9 char:11
+ &{Get-Stat <<<< -Entity $vms -Start $start -Stat $stat |
+ CategoryInfo : ResourceUnavailable: (mem.usage.average:String)
[Get-Stat], VimException
+ FullyQualifiedErrorId : Client20_RuntimeDataServiceImpl_CheckUserMetrics
_MetricDoesntExist,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetViStats
Get-Stat : 9/11/2014 7:53:26 PM Get-Stat The metric counter "disk.usa
ge.average" doesn't exist for entity "Windows Test VM - old".
At C:\temp\vm.ps1:9 char:11
+ &{Get-Stat <<<< -Entity $vms -Start $start -Stat $stat |
+ CategoryInfo : ResourceUnavailable: (disk.usage.average:String)
[Get-Stat], VimException
+ FullyQualifiedErrorId : Client20_RuntimeDataServiceImpl_CheckUserMetrics
_MetricDoesntExist,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetViStats
Get-Stat : 9/11/2014 7:53:26 PM Get-Stat The metric counter "net.usag
e.average" doesn't exist for entity "Windows Test VM - old".
At C:\temp\vm.ps1:9 char:11
+ &{Get-Stat <<<< -Entity $vms -Start $start -Stat $stat |
+ CategoryInfo : ResourceUnavailable: (net.usage.average:String)
[Get-Stat], VimException
+ FullyQualifiedErrorId : Client20_RuntimeDataServiceImpl_CheckUserMetrics
_MetricDoesntExist,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetViStats
Unable to find type [ordered]: make sure that the assembly containing this type
is loaded.
At C:\temp\vm.ps1:13 char:14
+ [ordered] <<<< @{
+ CategoryInfo : InvalidOperation: (ordered:String) [], RuntimeEx
ception
+ FullyQualifiedErrorId : TypeNotFound
Unable to find type [ordered]: make sure that the assembly containing this type
is loaded.
At C:\temp\vm.ps1:13 char:14
+ [ordered] <<<< @{
+ CategoryInfo : InvalidOperation: (ordered:String) [], RuntimeEx
ception
+ FullyQualifiedErrorId : TypeNotFound
Unable to find type [ordered]: make sure that the assembly containing this type
is loaded.
At C:\temp\vm.ps1:13 char:14
+ [ordered] <<<< @{
+ CategoryInfo : InvalidOperation: (ordered:String) [], RuntimeEx
ception
+ FullyQualifiedErrorId : TypeNotFound
Unable to find type [ordered]: make sure that the assembly containing this type
is loaded.
At C:\temp\vm.ps1:13 char:14
+ [ordered] <<<< @{
+ CategoryInfo : InvalidOperation: (ordered:String) [], RuntimeEx
ception
+ FullyQualifiedErrorId : TypeNotFound
Unable to find type [ordered]: make sure that the assembly containing this type
is loaded.
At C:\temp\vm.ps1:13 char:14
+ [ordered] <<<< @{
+ CategoryInfo : InvalidOperation: (ordered:String) [], RuntimeEx
ception
+ FullyQualifiedErrorId : TypeNotFound
Unable to find type [ordered]: make sure that the assembly containing this type
is loaded.
At C:\temp\vm.ps1:13 char:14
+ [ordered] <<<< @{
+ CategoryInfo : InvalidOperation: (ordered:String) [], RuntimeEx
ception
+ FullyQualifiedErrorId : TypeNotFound