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

Re: PowerCLI script for deploying VMs via template using guest customizations

$
0
0

Try something like this, it will create both groups of VM.

 

$templateNames="DR_WinXP","DR_Win7"
$customisationNames="WinXPCust","Win7Cust"
$vmNames="WinXP","Win7"

$numberOfVM=25,100
$dscName="DR_Workstations"

$dsc=Get-DatastoreCluster-Name$dscName
$numberOfGroups=$templateNames.Count

0..($numberOfGroups-1) |%{
 
$template=$templateNames[$_]
 
$oscust=$customisationNames[$_]
 
$name=$vmNames[$_]
 
$number=$numberOfVM[$_]
 
 
1..$number|%{
   
$suffix="{0:D3}"-f$_
   
New-VM-Name"$name_$suffix"-Template$template-OSCustomizationSpec$oscust-Datastore$dsc-WhatIf-RunAsync
  } 
}

Note that I included a WhatIf switch on the New-VM cmdlet, run the script first with this switch.

That way you know what the script will do, without actually creating the VMs.

Once you're happy remove the WhatIf switch


Viewing all articles
Browse latest Browse all 230200

Trending Articles



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