Simple script to power ON multiple VM’s in VMware using PowerCLI.

This script will check list of servers from the Powerstat.txt file and will PowerON VM’s that are in PoweredOFF state.

No action will be taken for PoweredON VM’s.

#Import VMware moduld
Get-Module -Name VMware* -ListAvailable | Import-Module
 
$file = "C:\Powerstat.txt"
$vms = Get-Content $file
Connect-VIServer <vCenter IP> -User 'domain\account' -Password 'XXXXXXXX'
Get-VM $vms | where {$_.Powerstate -eq "poweredOff"} | Start-VM -Runasync -Confirm:$false | Out-Null
Disconnect-VIServer -Confirm:$false

Leave a comment