Created
June 3, 2021 15:26
-
-
Save sandeep-sr/f309f259b656c0421ec9c026a125d609 to your computer and use it in GitHub Desktop.
powercli - Reboot multiple VM’s in a cluster
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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