itye1970
itye1970

Reputation: 1985

How can you list all vm private ips in an AZURE subscription?

enter image description hereI want to list all the private IP addresses assigned to vms in a subscription, is there a way to do this?

ie via portal or cli ?

Upvotes: 2

Views: 5243

Answers (1)

Daniel Björk
Daniel Björk

Reputation: 2507

Using PowerShell:

$vms = get-azvm
$nics = get-aznetworkinterface | where VirtualMachine -NE $null #skip Nics with no VM

foreach($nic in $nics)
{
    $vm = $vms | where-object -Property Id -EQ $nic.VirtualMachine.id
    $prv =  $nic.IpConfigurations | select-object -ExpandProperty PrivateIpAddress
    $alloc =  $nic.IpConfigurations | select-object -ExpandProperty PrivateIpAllocationMethod
    if ($vm.Name -NE $null) {
        Write-Output "$($vm.Name) : $prv , $alloc"
    }
}

Using the portal.

  1. Go to Virtual Machines
  2. Edit Columns
  3. Add Private IP Address

enter image description here

Upvotes: 4

Related Questions