VMware Cloud Community
tikondrus
Enthusiast
Enthusiast

deploy VM from template and customisation in powercli

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?

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership

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

Reply
0 Kudos
tikondrus
Enthusiast
Enthusiast

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

 

Reply
0 Kudos
LucD
Leadership
Leadership

Switch?
The DNS parameter on the Set-OSCustomizationSpec cmdlet accepts an array of strings.


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

Reply
0 Kudos
tikondrus
Enthusiast
Enthusiast

switch - I mean key -DNS. so I resolved my script and now everything is good

Reply
0 Kudos