Populate an array with
the information that you want to report.
$vAppNetworkAdapters = @()
foreach ($vApp in $vApps) {
$vms = Get-CIVM -VApp $vApp
foreach ($vm in $vms) {
$networkAdapters = Get-CINetworkAdapter -VM $vm
foreach ($networkAdapter in $networkAdapters) {
$vAppNicInfo = New-Object "PSCustomObject"
$vAppNicInfo | Add-Member -MemberType NoteProperty -Name VAppName -Value $vApp.Name
$vAppNicInfo | Add-Member -MemberType NoteProperty -Name VMName -Value $vm.Name
$vAppNicInfo | Add-Member -MemberType NoteProperty -Name NIC -Value ("NIC" + $networkAdapter.Index)
$vAppNicInfo | Add-Member -MemberType NoteProperty -Name ExternalIP -Value $networkAdapter.ExternalIpAddress
$vAppNicInfo | Add-Member -MemberType NoteProperty -Name InternalIP -Value $networkAdapter.IpAddress
$vAppNetworkAdapters += $vAppNicInfo
}
}
}
Running this script
retrieves the names of the virtual machines and their associated vApp, the IDs
of the NICs of the virtual machines, and external, and internal IP addresses of
the NICs.
|