Skip to content

Instantly share code, notes, and snippets.

@sajayantony
Last active August 29, 2015 14:27
Show Gist options
  • Save sajayantony/b6b41edacc5b947314a4 to your computer and use it in GitHub Desktop.
Save sajayantony/b6b41edacc5b947314a4 to your computer and use it in GitHub Desktop.
param(
[Parameter(Mandatory=$true)]
[string]$vmname
)
$ipAddresses = Get-VM -name $vmname | Select -ExpandProperty networkadapters | select IPAddresses
while ($ipAddresses.IPAddresses.Count -eq 0)
{
Write-Host "Waiting for VM to be ready"
Start-Sleep -Milliseconds 500
$ipAddresses = Get-VM -name $vmname | Select -ExpandProperty networkadapters | select IPAddresses
}
$vmIP = $ipAddresses.IPAddresses[0]
Write-Host "Ready with IP $vmIP"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment