Hi!
I try to deploy VM from template and customise it. For CustomSpec in WebUI I configured "enter a name in the clone/deploy wizard". And everything works ok when I deploy VM from UI.
But if I use Powercli I got the following error
New-VM : 1/21/2021 11:57:05 AM New-VM The operation for the entity "win2016" failed with the following message: "A specified parameter was not correct: hostname"
At line:25 char:1
+ New-VM -Name $VMName -Template $TempalateName -Datastore $DatastoreNa ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-VM], InvalidArgument
+ FullyQualifiedErrorId : Client20_TaskServiceImpl_CheckServerSideTaskUpdates_OperationFailed,VMware.VimAutomation.ViCore.Cmdlets.Commands.NewVM
How can I set the parameter hostname (computer name) in powercli?
Have a look at the Get-OSCustomizationSpec and Set-OSCustomizationSpec cmdlets.
There is a series of blog posts, starting with Working with Customization Specifications in PowerCLI Part 1, on the subject.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thanks a lot! I've already read these post. And I think that there is no way to set hostname with powercli.
I resolved my case using NamingScheme : Vm
Also from documentation it's not clear that for configuring multiple DNS servers I should use switch -dns $DNS1, $DNS2
Switch?
The DNS parameter on the Set-OSCustomizationSpec cmdlet accepts an array of strings.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
switch - I mean key -DNS. so I resolved my script and now everything is good