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

Re: VM Deployment with customization, parallel

$
0
0

Not to muddy the waters, but I have a new version I wrote internally that has some slight improvements if you want to give it a whirl.  I also have a couple different version to deploy to a DRS cluster as opposed to a host directly.  Let me know if maybe thist version works better?

 

 

########################################################### # Mark Jones 2/23/2012# Version 3# ##########################################################Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false$vcenter=Read-Host"Enter Vcenter Name"$csvimport=Read-Host"Enter CSV filename (fullname with extension)"$username=read-host"Enter your domain admin username for customization"$pass=Read-Host-AsSecureString"Enter your password"$adminpass=Read-Host-AsSecureString"Enter local admin password"#convert back to string$pass= [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pass) $pass= [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($pass) $adminpass= [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($adminpass) $adminpass= [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($adminpass) Connect-VIServer $vcenter$vmlist=Import-CSV$csvimportforeach ($itemin$vmlist) {     # I like to map out my variables    $basevm=$item.template     $datastore=$item.datastore     $vmhost=$item.vmhost     $custspec=$item.custspec     $vmname=$item.vmname     $ipaddr=$item.ipaddress     $subnet=$item.subnet     $gateway=$item.gateway     $pdns=$item.pdns     $sdns=$item.sdns     $vlan=$item.vlan     $location=$item.location              #Clone the templates    New-VM -Name $vmname -template $basevm -Location $location -Datastore $datastore -VMHost $vmhost -RunAsync } while (get-task -status running | Where-Object {$_.name -eq"clonevm_task"}) {     sleep20} foreach ($itemin$vmlist) {     $datastore=$item.datastore     $custspec=$item.custspec     $ipaddr=$item.ipaddress     $subnet=$item.subnet     $gateway=$item.gateway     $pdns=$item.pdns     $sdns=$item.sdns     $vlan=$item.vlan     $hd= [int]$item.ddrive *1024*1024    $vmname=$item.vmname     $cpu=$item.cpu     $mem= [int]$item.mem *1024   #set customization spec  New-OSCustomizationSpec -OSCustomizationSpec $custspec -Name $vmname -type NonPersistent | Out-Null  Set-OSCustomizationSpec -spec $vmname -AdminPassword $adminpass -DomainUsername $username -DomainPassword $pass -Confirm:$false  Get-OSCustomizationSpec $vmname | Get-OSCustomizationNicMapping | Set-OSCustomizationNicMapping -IpMode UseStaticIp -IpAddress $ipaddr -SubnetMask $subnet -DefaultGateway $gateway -Dns $pdns,$sdns          #Set network label    Get-VM -Name $vmname | Get-NetworkAdapter | Set-NetworkAdapter -NetworkName $vlan -Confirm:$false | Out-Null      #set vm    Set-VM -VM $vmname -OSCustomizationSpec $vmname -NumCpu $cpu -MemoryMB $mem -Confirm:$false      #Create D drive windows    if ($hd){     New-HardDisk -VM $vmname -CapacityKB $hd -ThinProvisioned:$true -Confirm:$false    }     #Remove Cust Spec        } foreach ($itemin$vmlist){ $vmname=$item.vmname #Start VM    Start-VM -VM $vmname -Confirm:$false -RunAsync } Disconnect-VIServer $vcenter -Confirm:$false

Viewing all articles
Browse latest Browse all 231440

Trending Articles



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