Hello All,
I need an updated script to show me how long 1 VM or a group of VMs have been powered on.
Had an outage a few days ago and I need to know which VMs where rebooted.
THANK YOU SO MUCH
Change the Get-VM at the beginning accordingly
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Did you check the events with Get-VIEvent?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you for you reply, very appreciated!
Can you help me with a full script utilizing Get-VIEvent?
You could do something like this, which will list all VMs that were powered on in the last 7 days, and will show the last poweron date.
$vms = Get-VM
$start = (Get-Date).AddDays(-7)
Get-VIEvent -Entity $vms -Start $start -MaxSamples ([int]::MaxValue) |
where{$_ -is [VMware.Vim.VmPoweredOnEvent]} |
Group-Object -Property {$_.VM.Name} -PipelineVariable group |
ForEach-Object -Process {
New-Object -TypeName PSObject -Property @{
VM =$group.Name
LastPowerOn = $group.Group | Sort-Object -Property CreatedTime -Descending |
Select -Last 1 | Select -ExpandProperty CreatedTime
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you so much!! will test as soon as possible
Is there a script to determine 1 or a handful of VMs how long they have been up?
Change the Get-VM at the beginning accordingly
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference