Last active
June 20, 2018 19:30
-
-
Save AspenForester/7ab174e2a9a962383e58a256ff0bb909 to your computer and use it in GitHub Desktop.
Used this to rapidly restart the VMs that got stuck rebooting after being patched. There may be other ways to get the list of machines to consider for restart other than a static list.
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
$vis = Connect-VIServer MyVcenter | |
$Servers = @("SomeServers") | |
foreach ($Server in $servers) | |
{ | |
if ( -not (Test-NetConnection -ComputerName $Server -CommonTCPPort SMB).TcpTestSucceeded ) | |
# Or maybe some other appropriate test or tests | |
{ | |
get-vm $Server | Restart-VM -Confirm:$false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment