Skip to content

Instantly share code, notes, and snippets.

@sandeep-sr
Created June 3, 2021 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sandeep-sr/f309f259b656c0421ec9c026a125d609 to your computer and use it in GitHub Desktop.
Save sandeep-sr/f309f259b656c0421ec9c026a125d609 to your computer and use it in GitHub Desktop.
powercli - Reboot multiple VM’s in a cluster
Get-Module -ListAvailable *vm*|Import-Module
$cred=Get-Credential
connect-viserver vcenter01 -Credential $cred
$vmlist=Get-Content C:\temp\rebootvms.txt
foreach ($vm in $vmlist)
{
get-cluster cluster02|get-vm $vm | Restart-VM -Confirm:$false
start-Sleep 2
Write-Output "$vm has been rebooted"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment