Guest User

Untitled

a guest
Jul 23rd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. $rgName = "kubetest"
  2. $vms = Get-AzureRmVM -ResourceGroupName $rgName
  3. $nics = Get-AzureRmNetworkInterface -ResourceGroupName $rgName
  4. $pubIPs = Get-AzureRmPublicIpAddress -ResourceGroupName $rgName
  5.  
  6. $vmNics = @{}
  7. $nics | ForEach-Object {
  8. $index = $_.id
  9. $value = $_
  10. $vmNics[$index] += @($value)
  11. }
  12.  
  13. $ipConfigs = @{}
  14. $pubIPs | ForEach-Object {
  15. $index = $_.IpConfiguration.id
  16. $value = $_
  17. $ipConfigs[$index] += @($value)
  18. }
  19.  
  20. $vms | ForEach-Object {
  21. $vm = $_
  22.  
  23. $nicIndex = $vm.NetworkProfile.NetworkInterfaces.id
  24. $nic = $vmNics[$nicIndex]
  25.  
  26. $configIndex = $nic.IpConfigurations.id
  27. $ipConfig = $ipConfigs[$configIndex]
  28.  
  29. [pscustomobject]@{VMName = $vm.Name;
  30. ComputerName = $vm.OSProfile.ComputerName;
  31. PrivateIP = $nic.IpConfigurations.PrivateIpAddress;
  32. PublicIP = $ipConfig.IpAddress}
  33. }
Add Comment
Please, Sign In to add comment