Windows – Create a Windows Schedule Task via GPO to run as specified user

group-policyscheduled-taskwindowswindows-server-2019

I am trying to create a Scheduled Task via Group Policy (Computer Configuration\Preferences\Control Panel Settings\Scheduled Tasks), to run as a specified domain service account.

However, when Group Policy tries to create the task, it fails with the following error.

"Group Policy Object did not apply because it failed with error code '0x80070005 Access is denied."

Here is what the scheduled task looks like from group policy.

Schedule Task in Group Policy

The task works fine if configured on the client itself (with the svc_hpia password stored)

But the password is not requested when configuring the task via Group Policy

The Group Policy scheduled task does get added if I tell it to use the NTAUTHORITY\SYSTEM account, but this is not desirable from a security perspective.

Is there a way I can get the scheduled task to create using my specified service account?

Best Answer

This is a GPP, right?

To avoid this issue, don't enable the Run in logged-on user's security context (user policy option) Common option when configuring user GPP Scheduled Tasks items.

Taken directly from the horse's mouth.