Microsoft Hyper V administrators facing day to day challenges to maintain the Virtualization environment stable with 100% up-time of Virtual Servers. Following script is just a basic example of getting Server up-time report on regular basic which can be scheduled with Windows Scheduler.
#Start-Process powershell -Verb runAs Administrator
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
$Server = Get-Cluster
$H=hostname
Get-VM –ComputerName (Get-ClusterNode –Cluster $Server)|Select-Object Name,Uptime | Export-Csv -Path C:\CSVMonitoringScript\$H.csv