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

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

$
0
0

LucD wrote:

 

Yes, you need to do a Start-VM to power it on.

In fact the sysprep part of the OSCustomizationSpec will run during the first boot.

Well these are linux boxes that I am trying to deploy, when I do a Start-VM $_."Server Name", it tries to power on the VM before it is done cloning.  I have the while loop, but it doesn't seem to want to wait.  It should try to clone both machines and then once they are done to power it on.

 

This is what I have

 

Import-Csv deploy.csv -UseCulture | %{     function UpdateVMSettings {     Write-Host "Changing Portgroup and virtual Hardware..."     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    }    Start-VM $_."Server Name"    Get-vm -Name $_."Server Name" | Get-NetworkAdapter | Where {$_.NetworkName -eq 140 } |Set-NetworkAdapter -StartConnected:$true -Connected:$true -NetworkName $_.VLAN -Confirm:$false       }

Viewing all articles
Browse latest Browse all 168400

Trending Articles



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