VMware Cloud Community

Apply-VMHostProfile Error: Invalid parameter type for parameter password

I'm trying to automate the answer file process before applying the host profile; I'm tired of mouse click and type several fields (about 10) for each server.

I've got a CSV file with all the info needed in the answer file and I go through it putting the values into a hash table where the keys are the required host profile inputs (get-vmhost esx17.domain.local |  Get-VMHostProfileRequiredInput | ft -autosize)

Running my script fails when it comes to the last (main) part, Apply-VMHostProfile; the command where the hash table is the input (-Variable $var).

Apply-VMHostProfile : 05.11.2015 15:13:47    Apply-VMHostProfile        The profile 'Initial-Setup' can not be applied on host 'esx17.domain.local': 'Invalid parameter type for parameter password'

At C:\admin\Scripts\apply-hostprofile-test1.ps1:115 char:53

+   Set-VMHost -VMHost $VMHost -State 'Maintenance' | Apply-VMHostProfile -Variabl ...

+                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidArgument: (:) [Apply-VMHostProfile], VimException

    + FullyQualifiedErrorId : Client20_SystemManagementServiceImpl_PrepareApplyVMHostProfileData_ExecuteHostProfileError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.ApplyVMHostProfile

The password is used for joining the active directory domain, so I'm giving 'authentication.activeDirectory.JoinDomainMethodPolicy.password' the password as value in the hash table.

This environment is a vSphere 5.5 - vCenter 5.5U2e with ESXi 5.5U2 and U3 hosts. I'm trying to apply to new U3 hosts.

I've also tried to convert the password to System.Security.SecureString (ConvertTo-SecureString -String $mypassword -AsPlainText -Force) but then I get a different error:

Apply-VMHostProfile : 05.11.2015 15:09:17    Apply-VMHostProfile        There was an error generating the XML document.

At C:\admin\Scripts\apply-hostprofile-test1.ps1:114 char:53

+   Set-VMHost -VMHost $VMHost -State 'Maintenance' | Apply-VMHostProfile -Variabl ...

+                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Apply-VMHostProfile], ViError

    + FullyQualifiedErrorId : Client20_SystemManagementServiceImpl_PrepareApplyVMHostProfileData_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.ApplyVMHostProfile

The script is a edited version of the one I found at NutzAndBolts: Automating ESXi Host Profile and Answer File with Powercli (Part 2) | NutzandBolts - An IT Systems E...

Does anyone know what 'parameter type' 'password' should be?

1 Reply

Did you ever get a solution to this?  Am trying to do similar but it keeps bugging out at the password section.  Have tried adding it as a secure string instead but it still seems unhappy:

Apply-VMHostProfile : 07/03/2017 10:33:26    Invoke-VMHostProfile        The

profile 'LDNDEV-HostProfile' can not be applied on host

'host1.test.domain': 'Invalid parameter type for parameter


At line:44 char:51

+ ... ntenance' | Apply-VMHostProfile -Variable $var -Confirm:$false | Test ..

+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidArgument: (:) [Invoke-VMHostProfile], Vim


    + FullyQualifiedErrorId : Client20_SystemManagementServiceImpl_PrepareAppl



But I get slightly different with a secure string:

Apply-VMHostProfile : 07/03/2017 11:11:10    Invoke-VMHostProfile        There

was an error in serializing body of message ExecuteHostProfileRequest: 'There

was an error generating the XML document.'.  Please see InnerException for

more details.

At line:44 char:49

+ ... intenance | Apply-VMHostProfile -Variable $var -Confirm:$false | Test ...

+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Invoke-VMHostProfile], ViErro


    + FullyQualifiedErrorId : Client20_SystemManagementServiceImpl_PrepareAppl