Q: How can I quickly find all virtual machines in Azure that have a reserved IP address?
A: Virtual machines on a virtual network can have an IP address assigned that will be maintained for the virtual machine even if the virtual machine is deprovisioned from the Azure fabric. The following PowerShell code shows all virtual machines, their cloud service, and whether they have an assigned, reserved IP address.
Get-AzureVM | Select-Object -Property Name, ServiceName, @{Name='ReservedIP';Expression={(Get-AzureStaticVNetIP -VM $_ ).IPAddress}} | Format-Table -AutoSize
To only show those with a reserved IP address, use the following code:
Get-AzureVM | Select-Object -Property Name, ServiceName, @{Name='ReservedIP';Expression={(Get-AzureStaticVNetIP -VM $_ ).IPAddress}} | Where-Object {$_.ReservedIP -ne $null} | Format-Table -AutoSize
0 comments
Hide comments