Hi
Can any one help on this script which was provided in here but the problem is it restart all the VM, and it cannot reboot when the VM in hung.
$vms = Get-VM -Name (Get-Content -Path C:\vm.txt)
Get-Stat -Entity $vms -Stat sys.uptime.latest -Realtime -MaxSamples 1 |
Select @{N='VM';E={$_.Entity.Name}},@{N='Uptime';E={[math]::Round((New-Timespan -Seconds $_.Value).TotalHours)}} |
where{$_.Uptime -gt 24} | %{
Get-VM -Name $_.VM |
Restart-VMGuest -Confirm:$false
}
Really need help here...
What do you get when you only execute the following ?
$vms = Get-VM -Name (Get-Content -Path C:\vm.txt)
Get-Stat -Entity $vms -Stat sys.uptime.latest -Realtime -MaxSamples 1 |
Select @{N='VM';E={$_.Entity.Name}},@{N='Uptime';E={[math]::Round((New-Timespan -Seconds $_.Value).TotalHours)}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
i can only test during non working hours, i'll update tomorrow
Fyi, the above lines do not change anything, nor do they restart any VM.
Just reporting on the Uptime
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference