phils85
Contributor
Contributor

Power on virtual machine after creation

Hi Community,

im using PowerCLI 5.5 to deploy VMs from a template. by using the vCenter i´m able to select the Option "Power on this virtual machine after creating" in the guest customization dialog.

Is there any option to set this by using the powercli? I didnt find anything using the documentation.

#Create Temp Spec

New-OSCustomizationSpec -Type NonPersistent -Name "Deployment" -OSType $VMOSType -FullName "name" -OrgName "org" -NamingScheme Fixed -NamingPrefix $VMName -AdminPassword $VMAdminPassword -TimeZone 110 -ChangeSid -Domain $VMDomain -DomainUsername $VMDomainJoinUser -DomainPassword $VMDomainJoinUserPassword -AutoLogonCount 1

#get the created spec

Get-OSCustomizationSpec "Deployment" | Get-OSCustomizationNicMapping | Set-OSCustomizationNicMapping -IpMode UseDHCP -EA SilentlyContinue | Out-Null

#new vm from template

$VMDeploymentStatus = New-VM -VMHost $VMDeploymentHost -Name $VMName -ResourcePool (Get-Cluster -VMHost $VMDeploymentHost | Get-ResourcePool $VMResourcePool | Select -First 1) -Datastore ( $VMDatastore = Get-VMHost $VMDeploymentHost | get-datastore $VMDatastore | Select -First 1) -Template $VMTemplate -OSCustomizationspec "Deployment" -DiskStorageFormat Thick -RunAsync

Ty.

0 Kudos
1 Reply
LucD
Leadership
Leadership

Have a look at Waiting for OS customization to complete


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos