VMware Cloud Community
marshawnm
Contributor
Contributor
Jump to solution

Deploy multiple VM from CSV file

Hi All,

I am new to powercli and powershell so pardon if my terminology isn't correct.  At this point I can really only modify scripts to work in my environment and that is what am attempting here.

I am trying to deploy a number of VMs with all required VM information contained in a CSV. 

The script is below attached.

The error I receive is this.

Get-VMHost : Cannot validate argument on parameter 'Name'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again.

I think am failing to pass the variable correctly here it is in the script

$VMHost = Get-VMHost $vm.host

But when I read in the CSV data using the Import-CSV cmdlet I get

Import-CSV Y:\file.csv

VMname        : CEIVIRPAS0158

VMhost        : ceiatlpvs0004.mgmt.int

datastore     : CEIVSC0002_EATL0NET03_LUN3

template      : W2008R2_SP1_EE_TEMPLATE

customization : CEI 2008

ipaddress     : 10.211.80.142

subnetmask    : 255.255.255.0

defaultgw     : 10.211.80.1

dns1          : 10.211.68.50

dns2          : 10.211.68.49

disktype      : Flat

storageformat : Thin2GB

capacityKB    : 20971520

Description   : RTIP Administration Web Server 9 of 10

any insight would be very help, thanks!

0 Kudos
1 Solution

Accepted Solutions
snoopj
Enthusiast
Enthusiast
Jump to solution

You sure you are using the right header names from the CSV file?  The error message seems to indicate that $vm.host is a $null value.

Your import seems to indicate that the values should be $vm.VMhost.  Unless I'm reading something wrong.  Same goes for the $VMName variable.  You have it set to $vm.name, but the import has it listed as $vm.VMname.

--j

View solution in original post

0 Kudos
3 Replies
snoopj
Enthusiast
Enthusiast
Jump to solution

You sure you are using the right header names from the CSV file?  The error message seems to indicate that $vm.host is a $null value.

Your import seems to indicate that the values should be $vm.VMhost.  Unless I'm reading something wrong.  Same goes for the $VMName variable.  You have it set to $vm.name, but the import has it listed as $vm.VMname.

--j

0 Kudos
marshawnm
Contributor
Contributor
Jump to solution

After reading your reply that was exactly the issue

THANKS A TON!

0 Kudos
snoopj
Enthusiast
Enthusiast
Jump to solution

No problem.  Glad to assist.

0 Kudos