PowerShell Snip of the Week (Get-SCVirutalNetworkAdapter)


powershell_2Ben Armstrong recently posted a method on Listing all the IP Addresses used by VMs.  The Method was pretty straight forward and gave back some great information.  It got me thinking of how enterprise customers could do this using System Center Virtual Machine Manager 2012 R2.  Here is what I came up with for this weeks PowerShell Snip of the Week.


Find IPv4 and IPv6 IP Addresses for all Running VMs:

Get-SCVirtualMachine | ? StatusString –eq “Running” | Get-SCVirtualNetworkAdapter | ft Name, IPv4AddressType, IPv4Addresses, IPv6Addresses –a



With this base there are a whole variety of options you could get from this if you twist the script a little.

Find Information about a server with a specific IP Address:

Sometimes in a troubleshooting scenario you get limited information.  Many times that information comes from the network team or from a Firewall log where only the an IP Address of a VM is known.

Get-SCVirtualMachine | Get-SCVirtualNetworkAdapter | ? IPv4Addresses –eq “IPADDRESS”


Get-SCVirtualMachine | Get-SCVirtualNetworkAdapter | ? IPv4Addresses -eq


This gets you some valuable information in your troubleshooting, most notably, the name of the VM so that you can now start to look at it directly.

Find VMs with duplicate MAC Addresses or Just track down a VM by MAC Address:

Modifying the script in a different way, looking for MAC Address, allows for another common troubleshooting scenario where VMs have the same virtual MAC Address.  It doesn’t happen all that often, but it can be tricky to track down when it does.  The following script will return the VM with the MAC Address you are looking for or multiple VMs if they share the same MAC Address.

Get-SCVirtualMachine | Get-SCVirtualNetworkAdapter | ? MACAddress -eq “<MACADDRESS>”


Get-SCVirtualMachine | Get-SCVirtualNetworkAdapter | ? MACAddress -eq “00:15:5D:F3:F8:03”

This entry was posted in Hyper-V, PowerShell, SCVMM, Windows Server 2012, Windows Server 2012 R2 and tagged , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s