Quantcast
Channel: Task Scheduler Managed Wrapper
Viewing all articles
Browse latest Browse all 2206

New Post: how to use a Group Managed service account to run a schedule task and make it "Run whether user is logged on or not"?

$
0
0
how can I use a Group Managed service account to run a schedule task and make it "Run whether user is logged on or not"?
https://technet.microsoft.com/en-us/library/hh831782.aspx this is some thing about Group Managed service accounts,
I tried several ways:
. use AddTask directly
    TaskService.Instance.AddTask("Test", new MST.DailyTrigger { DaysInterval = 1 },
                                    new MST.ExecAction("notepad.exe", "c:\\test.log", "c:\\program files\\"), "myDomain\\testMSA$", null, TaskLogonType.None);
only TaskLogonType.None can AddTask successfully, but the task is "Run only when user is logged on"

. RegisterTaskDefinition
MyTask.Folder.RegisterTaskDefinition(MyTask.Name, MyTask.Definition,
                            TaskCreation.CreateOrUpdate, "rmad\\testMSA$", null, TaskLogonType.None);
TaskLogonType.InteractiveToken and TaskLogonType.None can AddTask successfully, but the task is "Run only when user is logged on"

. change Principal
MyTask.Definition.Principal.UserId = "rmad\\testMSA$";
MyTask.Definition.Principal.LogonType = TaskLogonType.None;
MyTask.Folder.RegisterTaskDefinition(MyTask.Name, MyTask.Definition);
only TaskLogonType.InteractiveToken can AddTask successfully, but the task is "Run only when user is logged on"
at the same time, when I assigned TaskLogonType.None and TaskLogonType.Group, I got error "Value does not fall within the expected range"

In short, I can create a schedule task using Group Managed service accounts to run, but just can't make the task "Run whether user is logged on or not"

Viewing all articles
Browse latest Browse all 2206

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>