VMware Cloud Community
REED201110141
Contributor
Contributor

Importing IP addresses from CSV file.

I am setting the GuestNetworkInterface for about 100 VMs with PowerCLI.  Each is on a seperate 29-bit subnet.  I have a CSV file with the VM names, a CSV file with the IP addresses, and another one with the default gateways.  The IPs are all IPv4 dotted decimals with no other characters.

The following commands will successfully import and echo all the VM names.

$vms = Import-Csv servers.csv -Header "Server"

echo $vms

However the same commands on using IP.csv return nothing but blank carriage returns on the command line.

$IP = Import-Csv IP.csv -Header "IP Address"

echo $IP

The same is true when I use GW.csv with the dotted decimal default gateways.  I have to assume it has something to do with the data format.  Does anybody know what gives?

Tags (2)
0 Kudos
1 Reply
LucD
Leadership
Leadership

How does the content of your IP.csv look ?

Is it like this

"IP Address"

"192.168.1.1"

"192.168.1.2"

Notice how you can force the values to be strings.


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

0 Kudos