Hi Folks,
I am writing a script to extrapolate a number of specific Hyper-V VM queries on the SCVMM. Part of my script is to obtain all IP addresses from a VM. This is my script:
Powershell
$Data=@()$VMs="SOMEVM"foreach($VMin$VMs){$VMInfo=Get-VM-Name$VM$VMNetwork=$VMInfo|Get-VMNetworkAdapter$VMCustom=New-ObjectSystem.Object$VMCustom|Add-Member-TypeNoteProperty-NameIPAddresses-Value$VMNetwork.IPAddresses[0]$Data+=$VMCustom}$Data|Export-CSV"C:\output.csv"-Delimiter","-NoTypeInformation
When I run the script, I get the following:
"IPAddresses"
"10.10.x.x"
...which is fine and dandy, apart from the fact that when I run the command manually, the VM actually has more than one IP address:
Get-VM -Name SOMEVM | Get-VMNetworkAdapter
I get the following output:
Name IsManagementOs VMName SwitchName ...