Are all entries in that HostProfile filled in?
I mean, did you provide an answer file for all the fields that are returned by Apply-VMHostProfile?
The hostprofile consists only of configuration settings which don't require an answer. When the hostprofile is applied to the host then there are the following issues:
Firewall configuration: 40 issues
Advanced options: 7 issues
Service configuration: 1 issue
Date and time configuration: 1 issue
I ran a Get-VMHostProfileRequiredInput and I don't get any results returned.
Remediation through the webclient works. All settings are then applied. Only a reboot is required after hostprofile remediation for the settings to go into effect.
Did you also try with Invoke-VMHostProfile?
Anything in $answers?$esxName = 'MyEsx'
$profName = 'MyHostProfile'
$esx = Get-VMHost -Name $esxName
$prof = Get-VMHostProfile -Name $profName
$answers = Invoke-VMHostProfile -Entity $esx -Profile $prof -Confirm:$false
I ran the code you posted like this:
$esx = get-vmhost myesxhost
$prof = $esx | get-vmhostprofile
$esx is returning the host (Get-Member shows the type as VMware.VimAutomation.ViCore.Impl.V1.Inventory.VMHostImpl).
$prof is returning the hostprofile (Get-Member shows the type as VMware.VimAutomation.ViCore.Impl.V1.Host.Profile.VMHostProfileImpl).
$answers = Invoke-VMHostProfile -Entity $esx -Profile $prof
It asked to perform the operation which I allowed. A VIEvent is logged: "Host configuration changes applied."
$answers returns the esx host object. Get-Member returns the type as VMware.VimAutomation.ViCore.Impl.V1.Inventory.VMHostImpl.
Any more ideas?
That confirms that there are no missing values in the HostProfile.
What is now the status of the application of the HostProfile on that node?
Do you still see those missing values?
I had to run a Test-VMHostProfileCompliance -VMHost $esx after the previous Invoke-VMHostProfile -VMHost $esx. Now the hostprofile issues are resolved, except a reboot that is missing. I think the problem in my script was that I was using the -RunAsync Parametet for Invoke-VMHostProfile cmdlet. The next step in the script is a Test-VMHostProfileCompliance which was running while the previous command didn't even finish.
Thanks for your help, Luc!