Today I got a text from a co-worker who needed to shutdown a load of VMs before doing some maintenance, then power them all on after.
So here is a quick script I put together to do that
First put you list of VMs in a CSV file, formatted like this
VMname
VM1
VM2
VM3
then edit this script and set the path to your CSV and the FQDN of your vCenter.
$VMCSVPath = "C:\temp\VMs.csv"
$vCenter = "FQDN" # FQDN or Ip of the vCenter
$VMlist = import-csv $VMCSVPath
connect-viserver $vCenter
foreach ($VMname in $VMlist)
{
$VM = get-vm $VMname.VMname
# shut down a VM using the vmware tools
#if ($VM) {$VM | shutdown-guest -confirm:$false}
# power off a VM
#if ($VM) {$VM | stop-vm -confirm:$false}
# power on a VM
#if ($VM) {$VM | start-vm -confirm:$false}
}
Then remove the commant from the line you want to run (shutdown, power off or power on)