Retrieve Virtual machine IP

hello

when i use this command to retrieve vms ip: 

Get-VMNetworkAdapter *_DOL* | select vmname,ipaddresses | convertto-html |out-file  "c:\vmip.html"

I have no values on IPaddresses column, instead i have System.String[] value, i have tried to use Get-VMNetworkAdapter *_DOL* | select vmname,ipaddresses[0] to retrieve only ipv4 values but without result..

thanks 

June 30th, 2015 2:41am

Hallo zizou,

you can do this with a hash filter:

# Get all addresses
$IPAdresses = @{ N = "IPAdresses"; E = {$_.IPAddresses -join ","} }

# Get only the first address
# $IPAdresses = @{ N = "IPAdresses"; E = {$_.IPAddresses[0]} }

# Get Information
Get-VMNetworkAdapter *_DOL_* | Select vmname,$IPAddresses | ConvertTo-Html

Cheers,
Fred

Free Windows Admin Tool Kit Click here and download it now
June 30th, 2015 3:05am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics