Gaprofitt17
Enthusiast
Enthusiast

ALL IP addresses for each VM from import-list

Jump to solution

Hey All,

I'm trying to get all IP addresses from an import .csv list of VM's.  I'm either getting errors or only getting
one IP per VM? How do I accomplish this?

Thanks..

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

Assuming the CSV looks someting like this

VMname

vm1

vm2

the following should work.
Note that it requires the VMware Tools to be running in the guest OS.

$vmNames = Import-Csv -Path .\vmnames.csv -UseCulture

Get-VM -Name $vmNames.VMname |

Select Name,@{N='IP address';E={$_.guest.ExtensionData.IpAddress -join '|'}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
1 Reply
LucD
Leadership
Leadership

Assuming the CSV looks someting like this

VMname

vm1

vm2

the following should work.
Note that it requires the VMware Tools to be running in the guest OS.

$vmNames = Import-Csv -Path .\vmnames.csv -UseCulture

Get-VM -Name $vmNames.VMname |

Select Name,@{N='IP address';E={$_.guest.ExtensionData.IpAddress -join '|'}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos