ComputerManagementDsc
ComputerManagementDsc copied to clipboard
ScheduleTask doesn't work properly with domain credentials
If you use domain credentials with login like domain\username
or username@domain
, Test-DSCConfiguration will say that this resources not in desired state, because, as I understand, $task.Principal.UserId
which is used in Get-DSCConfiguration give you only username, without any domain specification.
Thank you for reporting this @popovmindbox . This should be an easy enough fix.
Just chiming in as a +1 that I ran into this issue in my usage as well. Inputting the username without the domain syntax works, however if someone wanted to use a domain credential for a different trusted domain then they might run into issues.
Thanks @ShawnHardwick - this should be a relatively easy fix - good for hacktoberfest :grin:
This is also one of those lovely differences in behavior between 2012 (R2) and 2016. Testing on my environment:
W2012R2 returns: DOMAIN\UserId W2016 returns: UserId
So this is tricky to fix, since W2016 doesn't return the domain. Unfortunately, I don't have a trusted forest to test with, I'm wondering how the different versions would return that.
Edit: Both operating systems are returning the same class though: Microsoft.Management.Infrastructure.CimInstance#root/microsoft/windows/taskscheduler/MSFT_TaskPrincipal2