I have created a new group managed service account in AD and added two servers to access the account. I am able to use the account in services.msc. It is accepting it there but when I am trying to schedule task in Task scheduler (using PowerShell command) I am getting error that user name or password is incorrect.
Register-ScheduledTask : The user name or password is incorrect. At line:4 char:1 + Register-ScheduledTask myAdminTask –Action $action –Trigger $trigger ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : AuthenticationError: (PS_ScheduledTask:Root/Microsoft/...S_ScheduledTask) [Register-ScheduledTask], CimException + FullyQualifiedErrorId : HRESULT 0x8007052e,Register-ScheduledTask
The command I am using is this:
$action = New-ScheduledTaskAction "C:\Users\admin\Desktop\backup.cmd" $trigger = New-ScheduledTaskTrigger -At 23:00 -Daily $principal = New-ScheduledTaskPrincipal -UserID abc\gmsa$ -LogonType Password Register-ScheduledTask myAdminTask –Action $action –Trigger $trigger –Principal $principal
I am using the right syntax for username (domainname\serviceaccount$).
FYI : I am testing this on win server 2016 on azure cloud.