gmsa scheduled task - run whether user is logged on or not

howbs2002 111 Reputation points
2021-10-29T19:23:28.45+00:00

I have a large number of scheduled tasks on a MS 2016 server, and I need to change them all to run using a gMSA, instead of a standard account.

I tried running the following, which worked, but I cannot figure out how to keep "Run whether user is logged in or not" selected.

schtasks /change /TN \taskname /RU DOMAIN\gmsaAccountName /RP

Run with highest privileges stays checked, but "Run whether user is logged in or not" changes to "run only when user is logged on"

I can recreate the task in PowerShell, and the setting is correct, but I am trying to avoid having to recreate all my tasks again from scratch, if there is a way to just use the schtasks /change command instead.

Appreciate any guidance on this.

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} vote

Accepted answer
  1. Rich Matheisen 47,901 Reputation points
    2021-10-29T20:10:56.763+00:00

    You need to create a new principal for the scheduled task. Something like this:

    $p = New-ScheduledTaskPrincipal -UserId DOMAIN\gmsaAccountName -LogonType Password
    Get-ScheduledTask <taskname>| 
        Set-ScheduledTask -Principal $p
    

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.