hope this would help you.
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-VM -Confirm:$false
}
as per LUC you do a replacement. Hope I am correct