I am having some trouble getting the formatting correct for my script. I am trying to use powercli with VMware to pull host name and IP info and from a vApp and export it to CSV.
So far I have:
$vapp = Get-CIVApp -name name_of_vApp
$vms = $vapp.ExtensionData.Children.vm
$output = foreach ($vm in $vms) {$vm | select-object -Property Name;$vm.Section[2].NetworkConnection | select-object -Property IpAddress,ExternalIpAddress;}
$output | export-csv -Path c:\temp\test.csv -NoTypeInformation
The problem, seems to be the line where I assign a value to $output
. For some reason it doesn't add the IP info, even though that works outside of the function or even inside the function without $vm.name. It just gives me the machine names separated by blank lines equal to the number of IP addresses that server has.
My ultimate goal is to have a three column table with the name of the server, the internal IP address and the external IP address. Any help would be appreciated.
Thanks in advance.