PowerTip: Get the public IP of an Azure VM with PowerShell


Summary: Use the Azure Resource Manager cmdlets to get the public IP address of an Azure virtual machine.

Hey, Scripting Guy! Question How can I get the public IP address information for an Azure Resource Manager virtual machine (VM)?

Hey, Scripting Guy! Answer All you need to do is use Get-AzureRmVm to find the VM and pass it to Get-AzureRmPublicIPAddress as in the following example:

Get-AzureRmVM -ResourceGroupName ‘HSG-ResourceGroup’ -Name ‘HSG-LinuxVM’ | Get-AzureRmPublicIpAddress

The Doctor

Comments (1)

  1. It might just be me, but this does not work with my version of AzureRM.

    Get-AzureRmVM -ResourceGroupName ‘HSG-ResourceGroup’ -Name ‘HSG-LinuxVM’ | Get-AzureRmPublicIpAddress

    Get-AzureRmPublicIpAddress : The Resource ‘Microsoft.Network/publicIPAddresses/HSG-LinuxVM’ under resource group ‘HSG-ResourceGroup’ was not found.
    StatusCode: 404
    ReasonPhrase: Not Found
    OperationID : ‘880e9f83-7b9d-449f-adc4-bf3e871122b6’
    At line:1 char:61
    + … sourceGroupName ‘HSG-ResourceGroup’ -Name ‘HSG-LinuxVM’ | Get-AzureRmPublicIpAddress
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : CloseError: (:) [Get-AzureRmPublicIpAddress], NetworkCloudException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Network.GetAzurePublicIpAddressCommand

    But this works:
    Get-AzureRmPublicIpAddress -ResourceGroupName ‘HSG-ResourceGroup’ -Name ‘HSG-LinuxVM’

Skip to main content