Reputation: 1985
I 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
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.
Upvotes: 4