VM Network Adapter Connection Check

Sometimes it’s nice to know if your VMs are connected. You’d think it’d be easy to check for network adapter connection state, but it’s not. Not in a pretty fashion that is. The script below will show you which VMs are currently unplugged in table format using PowerCLI:

$datacenter = "yourdc"
$VMs = (get-vm -location $datacenter)
$adapters = $VMs | get-networkadapter

$adapters | % {
  if(!($_| select-object -expandProperty connectionstate).connected) {
    @{$_.parent.name=($_| select-object -expandProperty connectionstate).connected}
  }
}

Leave a Reply