Hi sreed,
Be sure to post any code in “
” tags. You’ve replaced all your code with dummy data. I was only showing the method of running the disks through a foreach loop. You’ll still need your data. I’m not sure how the code you posted ended up with the output you show. Anyways, I took your original code and adjusted. Please give it a shot. Please note that the first time one of these servers has a second NIC added, you’ll get duplicated entries for that server.$report = @() $vms = Get-Azvm $nics = Get-AzNetworkInterface | ?{ $_.VirtualMachine -NE $null} $disk = get-azdisk foreach($nic in $nics) { $info = “” | Select ResourceGroupName,VmName,OStype,Interface,Adaptor,PrivIP,PublicIP,DiskName,DiskSize $vm = $vms | ? -Property Id -eq $nic.VirtualMachine.id $info.VMName = $vm.Name $info.ResourceGroupName = $vm.ResourceGroupName $info.Interface = $nic.name $info.Adaptor = $nic.IpConfigurations.Name $info.PrivIP = $nic.IpConfigurations.PrivateIpAddress $info.PublicIP = $nic.IPConfigurations.PublicIpAddress $info.OStype = $vm.StorageProfile.osDisk.osType $count = 1 foreach($d in $disks){ Add-member -InputObject $info -NotePropertyName "Disk$($count)Name" -NotePropertyValue $d.name Add-member -InputObject $info -NotePropertyName "Disk$($count)Size" -NotePropertyValue $d.disksizeGB $count++ } $report+=$info } $report | Sort-object PrivIP | Export-Csv -Path “c:\temp\AzureIP+Disk.Csv”Good luck.