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
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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.
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