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

Re: Using Powercli I having trouble modifying vm hardware and nic portgroup when deploying from template

$
0
0

Ok i made the change, not sure if it is right, when i run the script it proceeds to clone the vm but then prompts me if I want to configure parameters on testserver01, if i hit Y it gives an error(vm keeps cloning), then it starts the cloning of the second vm and prompts me again.  Below is the script and the error output.  THanks again for your help.

 

Import-Csv deploy.csv -UseCulture | %{      function UpdateVMSettings {      Write-Host "Changing Portgroup and virtual Hardware..."      Get-OSCustomizationSpec $_.Customization | Set-OSCustomizationSpec -MemoryMB $_.MemoryMB -NumCpu $_.NumCpu -Confirm:$false    Get-OSCustomizationSpec $_.Customization | Get-OSCustomizationNicMapping | where { $_.Position -eq '1'} | Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $_."IP Address" -SubnetMask 255.255.255.0 -DefaultGateway $_."GW" -Confirm:$false      Get-OSCustomizationSpec $_.Customization | Get-OSCustomizationNicMapping | where { $_.Position -eq '2'} | Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $_."Maint IP Address" -SubnetMask 255.255.0.0 -DefaultGateway $_."GW" -Confirm:$false      }            $vm=New-VM -Name $_."Server Name" -Template $_.Template -Host $_."Esx Host" -Datastore $_.Datastore -OSCustomizationSpec $_.Customization -Location "Deployed VMs" -Description $_.Description -Confirm:$false -RunAsync     while(!(Get-VM -Name $_."Server Name" -ErrorAction SilentlyContinue)){     sleep 120        Set-vm -VM $_."Server Name" | Get-NetworkAdapter | Where {$_.NetworkName -eq 140 } |Set-NetworkAdapter -StartConnected:$true -Connected:$true -NetworkName $_.VLAN -Confirm:$false         }`     

http://img825.imageshack.us/img825/5421/yfg.png

 

What I would like this to do is to clone the VM(s) first then when done to change the network adapter portgroup, is there a way to get it to clone the VM(s) first then change the portgroup?


Viewing all articles
Browse latest Browse all 208545

Trending Articles