VMware Cloud Community
COS
Expert
Expert
Jump to solution

Trying to use -OSCustomizationSpec getting error: "A specified parameter was not correct: hostname"

Below is the commandline I use to deploy a VM from a template...

New-VM -Name 'TestDeploy' -Template 'win2016x64' -Datastore 'superdoooperfast_ssd' -DiskStorageFormat Thin -Location (Get-Cluster -Name 'yomama' | Get-Datacenter | Get-Folder -Name 'Discovered virtual machine') -ResourcePool 'yomama'

That above works great. Now I need it to use a customization called 'win2016x64'.....

New-VM -Name 'TestDeploy' -Template 'win2016x64' -Datastore 'superdoooperfast_ssd' -DiskStorageFormat Thin -Location (Get-Cluster -Name 'yomama' | Get-Datacenter | Get-Folder -Name 'Discovered virtual machine') -ResourcePool 'yomama' -OSCustomizationSpec 'win2016x64'

This runs and the VM does deploy BUT! I get the error message below....

New-VM : 11/16/2018 9:13:57 AM New-VM          The operation for the entity "win2016x64" failed with the following message:

"A specified parameter was not correct: hostname"

The cluster called "yomama" that it is deploying to has DRS on if that means anything...….lol

Any ideas? Remember, I'm still a noooob at this.  (◔/‿\◔)

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Looks like the NamingScheme is not filled in.

Can you try setting it to take the name of the VM as the hostname with

Get-OSCustomizationSpec -Name win2016x64 | Set-OSCustomizationSpec -NamingScheme vm

When done, check the setting again (you should notice that the NamingScheme property has changed).

And then try the New-VM again.


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

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

I suspect the issue might be with your OSCustomizationSpec.
Can you check what is in there with

Get-OSCustomizationSpec -Name win2016x64 | Select *


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

0 Kudos
COS
Expert
Expert
Jump to solution

Here you go.

NOTE: Certain values were changed to protect the innocent...…..lol

Name                  : win2016x64

Type                  : Persistent

ServerId              : /VIServer=domainname\username@vc01.domainname.net:443/

Server                : vc01.domainname.net

LastUpdate            : 12/4/2017 9:42:19 AM

DomainAdminUsername   :

DomainUsername        :

Description           : GUI option, Datacenter license.  Power: high performance

AutoLogonCount        : 2

ChangeSid             : True

DeleteAccounts        : False

DnsServer             :

DnsSuffix             : {dns1.domainname.net, dns2.domainname.net}

Domain                :

FullName              : TECHNOLOGY

GuiRunOnce            : {reg delete HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate /v AccountDomainSid /f, reg delete HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate /v PingID /f, reg delete

                        HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate /v SusClientId /f, net stop wuauserv...}

NamingPrefix          :

NamingScheme          :

OrgName               : Department Of Always No Funding

OSType                : Windows

ProductKey            : xxxxx-xxxxx-xxxxx-xxxxx-xxxxx

TimeZone              : Pacific

Workgroup             : WORKGROUP

LicenseMode           : PerSeat

LicenseMaxConnections :

EncryptionKey         : {48, -126, 3, -30...}

ExtensionData         : VMware.Vim.CustomizationSpecItem

Id                    : win2016x64

Uid                   : /VIServer=domainname\username@vc01.domainname.net:443/OSCustomizationSpec=win2016x64/

Client                : VMware.VimAutomation.ViCore.Impl.V1.VimClient

AdminPassword         : <SOME_CRAZY_LONG_HASHED_VALUE>

DomainAdminPassword   :

DomainPassword        :

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Looks like the NamingScheme is not filled in.

Can you try setting it to take the name of the VM as the hostname with

Get-OSCustomizationSpec -Name win2016x64 | Set-OSCustomizationSpec -NamingScheme vm

When done, check the setting again (you should notice that the NamingScheme property has changed).

And then try the New-VM again.


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

0 Kudos
COS
Expert
Expert
Jump to solution

OK, ran it.

the line below went from this...

NamingScheme          :

To this...

NamingScheme          : Vm

And the commandline finished with the below results...

Name                 PowerState Num CPUs MemoryGB

----                 ---------- -------- --------

yomama               PoweredOff 1        3.000

Thanks again dude!!!

0 Kudos