Can i get PowerCLI Script for More than 10 Days Power off VM list in the VCenter... pls Assist
If my assumption was correct, try like this
$poweredOff = Get-VIEvent -Start (Get-Date).AddDays(-10) -MaxSamples ([int]::MaxValue) |
where{$_ -is [VMware.Vim.VmPoweredOffEvent]} | %{$_.Vm.Name}
Get-VM | where{$_.PowerState -eq 'poweredoff' -and $poweredOff -notcontains $_.Name} | select -ExpandProperty Name
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
To make sure I get the question, you want a script that lists the VMs that have been powered off for more than 10 days?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
If my assumption was correct, try like this
$poweredOff = Get-VIEvent -Start (Get-Date).AddDays(-10) -MaxSamples ([int]::MaxValue) |
where{$_ -is [VMware.Vim.VmPoweredOffEvent]} | %{$_.Vm.Name}
Get-VM | where{$_.PowerState -eq 'poweredoff' -and $poweredOff -notcontains $_.Name} | select -ExpandProperty Name
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You are right lucid ... thanks for your quick response...i will check and update you
Thanks Lucd your script work awesome... if possible , can i get VM power off date also.
That depends a bit on how long you keep the events on the vCenter.
The script could look something like the one in 2. Re: Powered off VM's and how long they have been powered off by.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference