VMware Cloud Community
V00Z11
Enthusiast
Enthusiast
Jump to solution

Remediate Host Profile

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

Reply
0 Kudos
1 Solution

Accepted Solutions
V00Z11
Enthusiast
Enthusiast
Jump to solution

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!

View solution in original post

Reply
0 Kudos
6 Replies
LucD
Leadership
Leadership
Jump to solution

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?


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

Reply
0 Kudos
V00Z11
Enthusiast
Enthusiast
Jump to solution

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.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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


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

V00Z11
Enthusiast
Enthusiast
Jump to solution

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? Smiley Happy

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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?


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

Reply
0 Kudos
V00Z11
Enthusiast
Enthusiast
Jump to solution

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!

Reply
0 Kudos