Thanks for your reponse. Now I'm getting:
Apply-VMHostProfile : Cannot validate argument on parameter 'Entity'. The argum
ent is null or empty. Supply an argument that is not null or empty and then try
the command again.
At C:\Scripts\Applyprofile.ps1:9 char
:32
+ Apply-VMHostProfile -Entity <<<< $($VMHost.NAME) -Profile YKFProfile -Co
nfirm:$false
+ CategoryInfo : InvalidData: (:) [Apply-VMHostProfile], Paramete
rBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutom
ation.ViCore.Cmdlets.Commands.Host.ApplyVMHostProfile
I have run the command successfully manually:
Apply-VMHostProfile -Entity "esxdc2s02.DOMAIN.local" -Profile MYPROFILE -Confirm:$false
Is it something to do with the -Entity switch?