View all VMs in an Azure Virtual Network

View all VMs in a Virtual Network and which ones are not in a virtual network.

John Savill

May 15, 2015

1 Min Read
View all VMs in an Azure Virtual Network

Q. How can I view all VMs in Azure that are in a Virtual Network?

A. I recommend always placing Azure VMs in an explicitly created virtual network which gives full control of the IP address space used and DNS configuration. To check what VMs are in a virtual network use the following PowerShell.

Get-AzureVM | where-object { $_.VirtualNetworkName -notlike "" } | select DeploymentName,HostName,VirtualNetworkName 

This will display information about all the VMs that are in a virtual network. You can also show VMs not in a virtual network using:

Get-AzureVM | where-object { $_.VirtualNetworkName -like "" } | select DeploymentName,HostName,VirtualNetworkName 

If you want to see the VMs in a specific virtual network add the network name in the PowerShell. For example:

Get-AzureVM | where-object { $_.VirtualNetworkName -like "VirtNet115" } | select DeploymentName,HostName,VirtualNetworkName

Note that you need to be running PowerShell 8.16 (run (Get-Module Azure).Version to check) or above for this to work as this enables access to the VirtualNetworkName property.

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like