

Write-Host($VM.VMName,’ ‘, $Adapter.Name, ‘ ‘, $Adapter.IPAddresses) Here is a script that I created for this purpose: $VMs = Get-VM If you want a list of virtual machines, their network adapter names, and their IPv4 addresses (without the IPv6 address), you will have to move beyond the command line and create a script. You can also see the IPv4 and the IPv6 addresses for each.Īs you can see in the figure above, some VMs have multiple network adapters, and each network adapter typically has both an IPv4 and an IPv6 address. If you look at the next screenshot, you can see that this particular VM has three virtual network adapters. Here is what the command looks like: Get-VM | Select-Object -ExpandProperty NetworkAdapters You can perform the expansion by using the Get-VM cmdlet in conjunction with the Select-Object cmdlet and the ExpandProperty switch. Expanding this property will allow PowerShell to display the virtual machine’s network configuration, including its IP address. The fact that the value is enclosed in braces indicates that NetworkAdapters is a property that can be expanded.

If you look closely, however, you will also notice that whereas the other properties shown in the screen capture have values associated with them, NetworkAdapters is showing a value of. As you read through the list of properties, you will notice that one of them is named NetworkAdapters. If you look at the screenshot below, you can see the last few items that were displayed. The screenshot above only shows part of the Get-VM cmdlet’s output. Even so, there is a way to determine the VM’s IP address and other network-related configuration settings. However, you might have noticed that the Get-VM cmdlet’s output does not list the virtual machine’s IP address. The screen capture shown above includes information that would be legitimately useful in a troubleshooting situation. You can see what this command’s output looks like in the screenshot below. If you want to see a more detailed view of the virtual machine’s various attributes, then enter this command: Get-VM | Select-Object * While the information shown on this screen can be helpful, it isn’t going to be sufficient for troubleshooting most networking problems.įortunately, the Get-VM cmdlet is capable of displaying much more detailed information than what is shown in the screenshot above. As you can see in the figure below, for example, PowerShell displays the VM’s state, how much memory the VM is using, and how long the VM has been running. Typing Get-VM DC causes PowerShell to display some really basic information about the VM. To show you what I mean, I have created a virtualized domain controller on a Hyper-V server. As handy as this cmdlet is, however, there is a limit to the information that it can provide.

One of the PowerShell cmdlets that administrators use most often to get information about a virtual machine is Get-VM. Fortunately, there are ways of gaining access to a virtual machine’s network configuration details (such as the IP address that the VM is using) without having to log into the VM to do so.

If a particular VM is experiencing network connectivity problems, for example, then the virtualization administrator might not be able to log into the VM to diagnose the problem. While there are undoubtedly advantages to segmenting administrative access rights in this way, doing so can also make it challenging to troubleshoot problems. In production environments, virtualization administrators rarely have permission to log into the virtual machines that they manage. Although that might have been the case at one time, IT responsibilities have become increasingly siloed in recent years. People who do not work in IT often assume that IT pros have access to absolutely all of their company’s IT resources.
