Is it possible to schedule a task in virtual center to check compliance of a profile via Powercli. I rather not do it on the virtual center for each profile. I could run a script to check compliance but I like the idea of just creating a scheduled task.
Yes, that is possible, but there is one remark.
The task will check the compliance of the HostProfile on all the associated ESXi nodes.
Although it should be possible according to the API Reference, I haven't been able to schedule it for 1 specific associated ESXi node.
$checkTime = Get-Date "05/31/2020 23:00"
$emailAddr = 'email@example.com'
$hp = Get-VMHostProfile -Name $hpName
$si = Get-View ServiceInstance
$scheduledTaskManager = Get-View $si.Content.ScheduledTaskManager
$spec = New-Object VMware.Vim.ScheduledTaskSpec
$spec.Name = 'Check HostProfile',$hp.Name,'on all associated ESXi nodes' -join ' '
$spec.Description = 'Check HostProfile'
$spec.Enabled = $true
$spec.Notification = $emailAddr
$spec.Scheduler = New-Object VMware.Vim.OnceTaskScheduler
$spec.Scheduler.runat = $checkTime
$spec.Action = New-Object VMware.Vim.MethodAction
$spec.Action.Name = 'CheckProfileCompliance_Task'