Hello PowerCLI Gurus,
Again I came up with a question
we are creating internal web portal in our organization to create VMs, we are using powercli with asp.net to work. and we are using very simple powercli command to accomplish this New-VM. I have one question, is there any way that we can change local administrator password of guest windows os on the fly?
will wait for reply.
Thanks in advance
Are you using an OSCustomizationSpec when deploying the new VM ?
In there you can change the local administrator password.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
hi LucD,
We are not using OsCustomization, and we want to set different password for each vm created. can you please guide me how can we achieve this using OsCustomization?
Thanks in advance
You can use a OSCustomizationSpec as the master, make a copy (non-persisent) for each VM you are deploying (with the New-OSCustomizationSpec cmdlet and the -OSCustomizationSpec parameter) .
Then change the administrator password in there (with the Set-OSCustomizationSpec cmdlet).
And use this updated OSCustomizationSPec to deploy the new VM.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
Thanks for the response.
I tried to accomplish as you mentioned but no luck, I found one script and it's perfect but I don't know where to put -AdminPassword. Following is the script
$specName = "tempSpec" + (Get-Random)
Get-OSCustomizationSpec -Name $spec | New-OSCustomizationSpec -Name $specName -Type NonPersistent
Get-OSCustomizationSpec -Name $specName | Get-OSCustomizationNicMapping | Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $ip -SubnetMask $netmask -DefaultGateway $gateway -Dns $DNSA
$tempSpec = Get-OSCustomizationSpec -Name $specName
$vmhost = (Get-Cluster | Get-VMHost | Sort-Object -Property MemoryUsageGB | Select-Object -First 1)
New-VM -Name $name -template $template -OsCustomizationSpec $tempSpec -VMHost $vmhost -Confirm:$true
Remove-OSCustomizationSpec -Confirm:$false -customizationSpec (Get-OSCustomizationSpec -name $specName)
will wait for the reponse
Thanks
You can do that like this
Get-OSCustomizationSpec -Name $spec | New-OSCustomizationSpec -Name $specName -Type NonPersistent
Get-OSCustomizationSpec -Name $specName | Set-OSCustomizationSpec -AdminPassword xyz
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
hi LucD,
I used the following script and it ran successfully but VM was not customized, it came as it was create as template, nothing has been changed not even IP
$vmname = "Test2008-1"
$vmtemplate = "Windows2008R2S"
$vmhost = "vmhost02.test.local"
$VLAN="25"
$ip = "10.101.35.50"
$subnetmask = "255.255.255.0"
$gateway = "10.101.35.1"
$dns = "10.101.35.5"
$DomainPass="somepass"
$DomainAccount="domain\someuser"
$Domain="domain"
$vmfolder = "MyFolder"
$datastore = "MyDS"
$cluster="MyClu"
$TimeZone = "035"
$Password = "Passw0rd"
$OrgName = "TestOrg"
$FullName = "fullname"
$ProdCode = "xxxx-xxxx-xxxx-xxxx-xxxx"
$oscustspec=$vmname+"-cust"
new-oscustomizationspec -name $oscustspec -ostype Windows -fullname $FullName -OrgName $OrgName -namingscheme Fixed -NamingPrefix $vmname -ProductKey $prodcode -LicenseMode Perseat -adminpassword $password -domain $domain -domainusername $DomainAccount -domainpassword $DomainPass -ChangeSid
Get-OSCustomizationNicMapping -Spec $oscustspec | set-oscustomizationnicmapping -ipmode UseStaticIP -IPAddress $ip -subnetmask $subnetmask -defaultgateway $gateway -dns $dns
New-VM -Name $vmname -Template $vmtemplate -VMHost $vmhost -datastore (get-datastore -name $datastore -vmhost $vmhost) -OSCustomizationSpec (Get-OSCustomizationSpec -name $oscustspec)
I don't know where I messed up the script.
waiting for your reply.
Thanks in advance.
Any clue in the customisation (see folder C:\Windows\Temp/vmware-imc) and/or sysprep logs (see KB2001932) ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
I have again tested the same script with windows 2012, it changed password but it needs manual intervention. like first I've to insert old password then it restart and then it ask for Language, keyboard selection and then it asked to click accept on license agreement.
setupact log
Setuperr log
waiting for the reply
Thanks
That error about the /shudown option is strange, that explains probably why the OSCustomizationSpec didn't get applied.
And since the sysprep didn't start, you get the prompt for the setup.
Now why this /shudown is in there is not clear to me.
Which vSphere versions are you running this against ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
vsphere 5.1
esxi 5.1
powercli
PowerCLI Version
----------------
VMware vSphere PowerCLI 5.5 Release 1 build 1295336
---------------
Snapin Versions
---------------
VMWare AutoDeploy PowerCLI Component 5.5 build 1262826
VMWare ImageBuilder PowerCLI Component 5.5 build 1262826
VMware vCloud Director PowerCLI Component 5.5 build 1295337
VMware License PowerCLI Component 5.5 build 1265954
VMware VDS PowerCLI Component 5.5 build 1295334
VMware vSphere PowerCLI Component 5.5 build 1295334
LucD,
I need your expert opinion, is it reliable to use oscustomization tool to auto provision vms using our custom asp.net based application.
will wait for your reply.
Thanks
I know this is old, but try using a non-sysprepped image. My customizations weren't working but now that i created a template without running sysprep, it works.