VMware Cloud Community
toon97
Enthusiast
Enthusiast
Jump to solution

PowerCLI Script to Shutdown VM's from an input file

Hi All,

Could anyone recommend a script for shutting-down vm's (gracefully) by taking the vm names from a file and then powering them off in that order.

I dont want to do this on a per host/VC level, it needs to be in a particular order.

Thanks!

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Does this do the trick.

The file should contain a name per line

Get-Content "C:\vms.txt" | %{
     Get-VM -Name $_ | Shutdown-VMGuest -Confirm:$false
}


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

View solution in original post

0 Kudos
1 Reply
LucD
Leadership
Leadership
Jump to solution

Does this do the trick.

The file should contain a name per line

Get-Content "C:\vms.txt" | %{
     Get-VM -Name $_ | Shutdown-VMGuest -Confirm:$false
}


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

0 Kudos