Last active
February 5, 2018 19:12
-
-
Save phwelo/6a7765d0441a8ed8101542baa4a2addc to your computer and use it in GitHub Desktop.
[Wait for IP Address] Wait for VM to come up (evaluate by IP address) PowerCLI #Powershell #VMWare
This file contains hidden or 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
function WaitForBoot($VM) { | |
$TimeOut = New-TimeSpan -Minutes 2 | |
$StopWatch = [diagnostics.stopwatch]::StartNew() | |
while ($StopWatch.elapsed -lt $TimeOut) { | |
$VM = Get-VM -name $VM | |
if ($VM.Guest.IPAddress) { | |
write-host 'Cool' | |
return | |
} | |
for ($i=0; $i -le 4; $i++) { | |
write-host -NoNewline '.' | |
start-sleep -seconds 1 | |
} | |
} | |
write-warning "Timed out connecting to $VM. Moving on to next." | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment