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

Re: Create VM using PowerCLI and csv file

$
0
0

A very simple and straightforward brake system :-)

 

## Deploy VMs from CSV File
## Much borrowed from http://communities.vmware.com/thread/315193?start=15&tstart=0$maxJobs=3
$currentJobs
=0
## Imports CSV file
Import-Csv"C:\temp\TestDeploy1"-UseCulture|%{## Gets Customization info to set NIC to Static and assign static IP address    Get-OSCustomizationSpec$_.Customization|Get-OSCustomizationNicMapping|`
## Sets the Static IP info
    Set-OSCustomizationNicMapping-IpModeUseStaticIP-IpAddress$_."IP Address"`
        -SubnetMask$_.Subnet-DefaultGateway$_.Gateway-Dns$_.DNS
## Sets the name of the VMs OS
    $cust=Get-OSCustomizationSpec-NameTest
    Set-OSCustomizationSpec-OSCustomizationSpec$cust-NamingSchemeFixed-NamingPrefix$_.VMName
## Creates the New VM from the template
    $vm=New-VM-Name$_."Server Name"-Template$_.Template-Host$_."Esx Host"`
        -Datastore$_.Datastore-OSCustomizationSpec$_.Customization`
       
-Confirm:$false-RunAsync

   
$currentJobs=Get-Job-StateRunning|Measure-Object|Select-ExpandPropertyCount
   
while($currentJobs-ge$maxJobs){      sleep30
     
$currentJobs=Get-Job-StateRunning|Measure-Object|Select-ExpandPropertyCount
    }
## .......}

 

You can be more selective on getting the current jobs. You could for example check if the name of the jobs shows that they are actually cloning jobs.


Viewing all articles
Browse latest Browse all 252940

Trending Articles



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