July 1st, 2016

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

Doctor Scripto
Scripter

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

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

3 comments

Discussion is closed. Login to edit/delete existing comments.

  • ARUNKUMAR S

    It doesn’t work

    Error : The Resource ‘Microsoft.Network/publicIPAddresses/myVM’ under resource group ‘myGroup’ was not found

  • wang tianshu

    Answer doesn’t work.

    PS C:\Users\> Get-azureRMvm -ResourceGroupName demo -Name centos|Get-AzureRmPublicIpAddressGet-AzureRmPublicIpAddress : The Resource ‘Microsoft.Network/publicIPAddresses/centos’ under resource group ‘demo’ wasnot found.StatusCode: 404ReasonPhrase: Not FoundOperationID : ‘6505ce86-42ff-413a-b1e8-fc66893a1a25’At line:1 char:52+ … eRMvm -ResourceGroupName demo -Name centos|Get-AzureRmPublicIpAddress+ ~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo : CloseError: (:) [Get-AzureRmPublicIpAddress], NetworkCloudException+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Network.GetAzurePublicIpAddressCommand

  • Simonelli, Franco D.

    Doens’t work, sir.