6 Replies Latest reply on Jun 14, 2018 10:50 PM by V00Z11

    Remediate Host Profile

    V00Z11 Novice

      Is there any way to invoke a host profile remediate on a vmhost via PowerCLI?

      When I use Invoke-VMHostProfile on a newly installed host the profile is applied to the host but there are multiple issues still open until I remediate the host via the webclient.

      PowerCLI 6.5.4
      vCenter/ESXi 6.0u3

        • 1. Re: Remediate Host Profile
          LucD Guru
          Community WarriorsUser ModeratorsvExpert

          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?

          • 2. Re: Remediate Host Profile
            V00Z11 Novice

            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.

            • 3. Re: Remediate Host Profile
              LucD Guru
              vExpertCommunity WarriorsUser Moderators

              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

              1 person found this helpful
              • 4. Re: Remediate Host Profile
                V00Z11 Novice

                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?

                • 5. Re: Remediate Host Profile
                  LucD Guru
                  User ModeratorsvExpertCommunity Warriors

                  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?

                  • 6. Re: Remediate Host Profile
                    V00Z11 Novice

                    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!