I wrote this PowerCLI line to create a new vm from a template and use the OSCustomizationSpec option.
New-VM -Name $VMName -Template 'Svr_2k3_std' -VMHost $VMHost -DiskStorageFormat Thin -OSCustomizationSpec $OSCust -ResourcePool 'Test' -Datastore 'OS2'
All works fine untill the very end where I get this msg:
I believe this is because I left the server name blank in the OS customization. Is there a way to provide that information in this PowerCLI command?
Thx,
Scott
Interesting.
You can use something like the following to define OSCustomization and then use it during the VM creation.
Set-OSCustomizationSpec $OSCust -NamingScheme VM
New-VM -Name $VMName -Template 'Svr_2k3_std' -VMHost $VMHost -DiskStorageFormat Thin -OSCustomizationSpec $OSCust -ResourcePool 'Test' -Datastore 'OS2'
Let me know how you go.
Grant
Hi Scott,
The OS Customisation Spec only takes effect once the VM is powered on for the first time. The error sounds like the VM is not being created - is that right?
A few things for you to check:
1. Does the $VMHost value have visibility onto the datastore you are trying to connect to?
2. If you substitute the $VMHost and $VMName with values (rather than variables) do you have the same issue?
Grant
The variables are valid and the VM is copied, but in the last 2 or 3% is when I get the error. If I create a OS customization that does not ask any questions it creates fine.
Thx,
Scott
Interesting.
You can use something like the following to define OSCustomization and then use it during the VM creation.
Set-OSCustomizationSpec $OSCust -NamingScheme VM
New-VM -Name $VMName -Template 'Svr_2k3_std' -VMHost $VMHost -DiskStorageFormat Thin -OSCustomizationSpec $OSCust -ResourcePool 'Test' -Datastore 'OS2'
Let me know how you go.
Grant
Quick thought - can you check if the Sysprep files are on your vCenter Server at C:\ProgramData\VMware\VMware VirtualCenter\sysprep for 2003?
This is per http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=100559...
Grant
Are you running the script from the 32-bit PowerCLI prompt ?
There are some issues when you use customization from the 64-bit PowerCLI prompt.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
@GrantOrchard I could use the Set-OSCustomizationSpec, but I don't want to change it just answer the question of what should the server name be. I did check the sysprep and it looks fine, it works fine if I build a server thru the GUI and answer that name question.
@LucD I am using the 32-bit version. I was listening to a podcast last night with Glen Sizemore, where he said the samething about the 64-bit version having some issues.
If I have to I could just build the OS customization in a powercli line for each server build, but I would rather use what I have built already.
Thx,
Scott
You are apparently using an OSCustomization spec that prompts for a value (the servername in your case).
Afaik that doesn't work.
Which is, in my opinion, kinda logical, you're using PowerCLI which is an automation tool, so prompting for a value is not really an automated procedure.
Why don't you use -NamingScheme VM ?
In that case the name will be the same as the name of the VM, and you can easily control that name from a script.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
-NamingScheme VM
Is the correct answer. I did not fully understand what that ment till I just tried it. I'll be changing this in all my OS customizations to use this.
Thanks all,
Scott