Skip to content

Instantly share code, notes, and snippets.

@jcpowermac
Created December 11, 2013 18:50
Show Gist options
  • Select an option

  • Save jcpowermac/7916185 to your computer and use it in GitHub Desktop.

Select an option

Save jcpowermac/7916185 to your computer and use it in GitHub Desktop.
Virtual machines that are not connected to their network
$vmview = Get-View -ViewType VirtualMachine
$vmview | % {
if( $_.Runtime.PowerState -eq "poweredOn" ) {
$netdev = $_.Config.hardware.Device | Where {$_.MacAddress}
if(!($netdev.Connectable.Connected) ) {
$hostname = (Get-View -id $_.Runtime.Host).Name
Write-Host $_.Name $netdev.Backing.Port.PortKey $hostname
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment