Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
powercli - Stop or power-off multiple VM’s
Get-Module -ListAvailable *vm*|Import-Module
Connect-VIServer vcenter01 -Credential $cred
$deletevmlist=Get-Content C:\temp\stopvms.txt
foreach($vm in $deletevmlist)
$vmstate=get-vm $vm
if($vmstate.PowerState -eq "PoweredOn")
write-output ("$vm is powered-on hence stopping it")
Stop-VM -VM $vm -Confirm:$false -RunAsync | Out-Null
Start-Sleep 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment