VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot

Power-Off VMs which are under particular folder

Hi All,

I am looking for a script which can Power-Off and Power-On All VMs based on folder level. Please help

Get-VM | where {$_.status -eq "powered on"} | Poweroff-VM

Thanks

Madhu

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership

You mean like this

Get-VM -Location (Get-Folder -Name MyFolder) | where {$_.status -eq "powered on"} | Poweroff-VM


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
ganapa2000
Hot Shot
Hot Shot

Thanks a lot LuCD as always, you are the best Smiley Happy

I had make little changes and below one worked.

Get-VM -Location (Get-Folder -Name MyFolder) | where {$_.PowerState -eq "PoweredOn"} | Shutdown-VMGuest

Reply
0 Kudos