Task.Definition.Principal.Account is null if in the UserId property of the task XML, is set in plain text, instead of SID
See original GitHub issueI need to get a task’ associated principal, which is set in ‘When running the task use the following user account’. However, on some machines, the UserId in the task’s XML is represented by Sid:
<Principal id="Author">
<RunLevel>HighestAvailable</RunLevel>
<UserId>S-1-5-21-2025382838-34760544-43243242434-1106</UserId>
<LogonType>Password</LogonType>
</Principal>
In which case this works fine and I can retrieve the account, but on other machines the UserId is represented in plain text:
<Principal id="Author">
<RunLevel>HighestAvailable</RunLevel>
<UserId>Domain\User</UserId>
<LogonType>Password</LogonType>
</Principal>
In which case Task.Definition.Principal.Account
returns null
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
TaskScheduler RegisterTaskDefinition fails with (38:4)UserID
Question. How do you register a scheduled task with the Task Scheduler 2.0 COM object API? Look at the answer in the back...
Read more >Principal.UserId property - Win32 apps
When reading or writing XML for a task, the user identifier for the principal is specified using the UserId element of the Task...
Read more >Chapter 15 SQL Structured Query Language
In this chapter, we will focus on using SQL to create the database and table structures, mainly using SQL as a data definition...
Read more >Configure Windows service accounts and permissions
This article helps advanced users understand the details of the service accounts. Most services and their properties can be configured by using ...
Read more >SQL MP Run As Accounts – NO LONGER REQUIRED
This creates a login in SQL, and allows the SCOM agent to be able to monitor SQL server, without having to maintain another...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@karthimahendran Use the Account property. It will always return the username.
@msmilkoff I’m glad this fixed your problem. I’ll publish 2.8.16 today with the fix.
Thanks for your workaround. It helped me have an idea as to how to prevent even though this is really Microsoft’s library’s problem. I’ll look into it and let you know what I find.