Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 226966

Re: Deploying, customizing, and modifying VMs from a csv file

$
0
0

Hi

 

assuming this is your csv file

    "name","ip","netmask","gateway","dns","networkName"
    "TESTSRV1","10.244.186.136","255.255.255.0","10.244.186.1","10.244.37.25;10.244.37.26","VLAN186_QA"

you have one problem. You can't save any arrays into a csv and make powershell recognize them natively.

Instead, use a custom delimiter (not the same as csv uses!) and split them - at import - into an array. Look at the semicolon between the two dns servers.

 

    $newVmList=Import-Csvtest.csv | Select-Object-Property"name", "ip", "netmask", "gateway", @{Name = "dns"; Expression = {$_.dns -split";"} }, "networkName"

 

The resulting object looks like this

    name       : TESTSRV1
    ip         : 10.244.186.136
    netmask    : 255.255.255.0
    gateway    : 10.244.186.1
    dns        : {10.244.37.25, 10.244.37.26} <-- Array
    networkName: VLAN186_QA

 

Regards

Emanuel


Viewing all articles
Browse latest Browse all 226966

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>