Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $rgName = "kubetest"
- $vms = Get-AzureRmVM -ResourceGroupName $rgName
- $nics = Get-AzureRmNetworkInterface -ResourceGroupName $rgName
- $pubIPs = Get-AzureRmPublicIpAddress -ResourceGroupName $rgName
- $vmNics = @{}
- $nics | ForEach-Object {
- $index = $_.id
- $value = $_
- $vmNics[$index] += @($value)
- }
- $ipConfigs = @{}
- $pubIPs | ForEach-Object {
- $index = $_.IpConfiguration.id
- $value = $_
- $ipConfigs[$index] += @($value)
- }
- $vms | ForEach-Object {
- $vm = $_
- $nicIndex = $vm.NetworkProfile.NetworkInterfaces.id
- $nic = $vmNics[$nicIndex]
- $configIndex = $nic.IpConfigurations.id
- $ipConfig = $ipConfigs[$configIndex]
- [pscustomobject]@{VMName = $vm.Name;
- ComputerName = $vm.OSProfile.ComputerName;
- PrivateIP = $nic.IpConfigurations.PrivateIpAddress;
- PublicIP = $ipConfig.IpAddress}
- }
Add Comment
Please, Sign In to add comment