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 Engineer Experiences
Does anyone know what 'parameter type' 'password' should be?