Some PowerShell and Windows Hyper-V 2012, find VM´s not connected
Digging around in the powershell module for Hyper-V have given me some ideas on what you can do.
Have you ever wondered about if you have a VM that is not connected to any network?
First you use the script part I showed in an earlier post, how to find Hyper-V servers in your AD :
$VMhosts = Get-ADObject -Filter 'Name -like "*Hyper-V"' | %{$_.DistinguishedName.Split(",")[1].replace("CN=","") }
And then you can run the following to list all VM´s that are not connected to any virtual network
$VMhosts | %{ Get-VM -ComputerName $_ | Get-VMNetworkAdapter | where SwitchName -eq $null}
In this little screendump you can see for all my Hyper-V hosts what VM´s without a network connection, you can also easily change the -eq $null to a switch name and then get what VM´s are connected to that particular virtual switch on all your hosts
good luck 🙂
Comments
wikilaan
vNiklas Virtualization blog » Some PowerShell and Windows Hyper-V 2012, find VM´s not connected