Skip to content

Instantly share code, notes, and snippets.

@phwelo
Last active February 5, 2018 19:12
Show Gist options
  • Save phwelo/6a7765d0441a8ed8101542baa4a2addc to your computer and use it in GitHub Desktop.
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
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