-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
xScheduledTask: Cannot create task to run as NetworkService #130
Comments
Great info @jpuskar - thanks for raising this! Should be enough for me to get onto fixing ASAP! Awesome stuff! |
The same would apply if you use the BUILTIN\Administrators group. |
I've been a bit (a lot) snowed under lately, but hopefully things will slow down by this weekend and I'll get some DSC work done. Again - sorry this has all been taking so long. |
Unfortunately I can't resolve this issue without a change to DSC itself. There is a user voice issue open to enable blank passwords to be passed to a DSC Resource: https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/13447689-dsc-should-allow-credentials-with-blank-passwords But there is no ETA on when this will be fixed. |
There are two other possibilities of solving this problem (neither are ideal), but until this limitation in DSC is addressed then they should be considered:
e.g. $network_service_cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList ("NT AUTHORITY\NETWORK SERVICE", (ConvertTo-SecureString -String 'WhoCares' -AsPlainText -Force))
xScheduledTask 'sql_backups_daily'
{
TaskName = 'my_task'
TaskPath = '\CustomTasks'
ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe'
ActionArguments = "-File `"C:\scripts\my_script.ps1`""
ScheduleType = 'Daily'
DaysInterval = 1
RepetitionDuration = 'Indefinitely'
ExecuteAsCredential = $network_service_cred
LogonType = 'ServiceAccount'
Enable = $true
} @jpuskar , @ketjap, @johlju - do you have any opinion on this one? |
I would go for option 2 because it is not a breaking change (?) and it is easy to reverse without another breaking change when the limitation is resolved, which would not be the case with option 1. So option 2 seems to me as the best option. |
Ignoring the password might also allow it to work for (g)MSAs, which is currently doesn't. But in that case you can't use |
I think (g)MSA is ending with |
@johlju true, though gMSAs are subclassed from computers anyway, so it would make sense to use the same rules for a computer or a gMSA, since their mechanism should basically be the same. It's an odd use case to have a scheduled task on a machine run as a computer other than itself (which would be achieved with |
Never tried running a schedule task as the computer account, but in theory I think you could assign permission using the computer account those allowing a job to access resources 🤔 But that must be an edge case. |
Might be worth putting together a table of all possible username/password and how they should be treated? I'll see if I can put something together this week. |
xWebAdministration's xWebAppPool also has this issue with gMSAs. It would be good (IMO) if both modules handled special accounts in the same manner. See dsccommunity/WebAdministrationDsc#80 for the gMSA issue |
Maybe the solution should bring ScheduledTask resource into alignment with the Service resource which has a separate property BuiltInAccount? Service |
See my pull request |
New pull request: |
Verbose Change Log for pull request, putting it here so there is a record of the design decisions when implementing fix. Added BuiltInAccount Property to allow running task as one of the build in service accounts
|
ScheduledTask: Added BuiltInUser (Issue #130) & Fixed IdleWaitTimeout…
@PlagueHO Can we closes this now the fix is merged into dev? |
Yep. Good point. Thank you for your hard work!! |
This logic would need changed such that if logontype is 'serviceaccount' and the password is null or empty, don't set the password.
Example resource which should work, but fails with a 'password is null' error due to the logic above.:
The text was updated successfully, but these errors were encountered: