A piece of code to Power Down the list of ESXi hosts

We had a quick requirement to power down the entire VMware ESXi environment and we powering down one by one was time consuming work so created this piece of code to bring all them down at once.

All we had to do is placing a text file named “VM_list.txt” in a folder, updating the FQDNs of all the host and executing the PowerShell script in the folder.

Just for sharing purpose I’m just adding this to the blog…
$vmList = Get-Content ".\VM_list.txt"
echo ""
echo ""
foreach($line in $vmList)
   echo ""
   echo  $line
   echo "============"
   echo ""
   Get-VMHost -Name $line | Stop-VMHost -Confirm:$false -Force 
   $count = $count + 1
echo ""
Click to rate this post!
[Total: 1 Average: 5]

Leave a Reply

Your email address will not be published. Required fields are marked *