Hello
I am trying to pull a list of VMs with their Get-Stat for uptime and the VM name. I am having a little trouble getting these in a clean manner.
Below is what works fine for pulling a single VM uptime
Get-Stat -Entity testvm -Stat 'sys.osuptime.latest' -Realtime -MaxSamples 1 -ErrorAction SilentlyContinue | Select @{N='Uptime (d.hh:mm:ss)';E={[timespan]::FromSeconds($_.value)}}
But I would like to put a Get-Folder or Get-VM 'format of vm names' | <then the above code> to output to a more digestible format like Name | Uptime (d.hh:mm:ss) .
Try something like this
Get-Stat -Entity $vms -Stat 'sys.osuptime.latest' -Realtime -MaxSamples 1 -ErrorAction SilentlyContinue |
Select @{N = 'VM'; E = {$_.Entity.Name}},
@{N = 'Uptime (d.hh:mm:ss)'; E = {[timespan]::FromSeconds($_.value)}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try something like this
Get-Stat -Entity $vms -Stat 'sys.osuptime.latest' -Realtime -MaxSamples 1 -ErrorAction SilentlyContinue |
Select @{N = 'VM'; E = {$_.Entity.Name}},
@{N = 'Uptime (d.hh:mm:ss)'; E = {[timespan]::FromSeconds($_.value)}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Luc! Thank you!
I was close; had my syntax order wrong. Appreciate the help!