ComputerManagementDsc
ComputerManagementDsc copied to clipboard
xScheduledTask: test is always false
Details of the scenario you tried and the problem that is occurring: Simply want to deploy 3 scheduled tasks. I run Start-Dsc... and it works perfectly and creates scheduled tasks that work without issues. However, when I run test, I receive False:
VERBOSE: [tst01sp16]: LCM: [ Start Resource ] [[xScheduledTask]SiteCreationTask]
VERBOSE: [tst01sp16]: LCM: [ Start Test ] [[xScheduledTask]SiteCreationTask]
VERBOSE: [tst01sp16]: [[xScheduledTask]SiteCreationTask] Testing scheduled task 'Mitt Skap Personal Site Creation' in '\'.
VERBOSE: [tst01sp16]: [[xScheduledTask]SiteCreationTask] Getting scheduled task 'Mitt Skap Personal Site Creation' in '\'.
VERBOSE: [tst01sp16]: [[xScheduledTask]SiteCreationTask] Task 'Mitt Skap Personal Site Creation' found in '\'. Retrieving settings, first action, first trigger and repetition settings.
VERBOSE: [tst01sp16]: [[xScheduledTask]SiteCreationTask] Detected schedule type 'Daily' for first trigger.
VERBOSE: [tst01sp16]: [[xScheduledTask]SiteCreationTask] Current scheduled task values retrieved.
VERBOSE: [tst01sp16]: [[xScheduledTask]SiteCreationTask] Testing DSC parameter state.
VERBOSE: [tst01sp16]: LCM: [ End Test ] [[xScheduledTask]SiteCreationTask] False in 2.4840 seconds.
VERBOSE: [tst01sp16]: LCM: [ End Resource ] [[xScheduledTask]SiteCreationTask]
VERBOSE: [tst01sp16]: LCM: [ Start Resource ] [[xScheduledTask]SiteProvisioningTask]
VERBOSE: [tst01sp16]: LCM: [ Start Test ] [[xScheduledTask]SiteProvisioningTask]
VERBOSE: [tst01sp16]: [[xScheduledTask]SiteProvisioningTask] Testing scheduled task 'Mitt Skap Site Provisioning' in '\'.
VERBOSE: [tst01sp16]: [[xScheduledTask]SiteProvisioningTask] Getting scheduled task 'Mitt Skap Site Provisioning' in '\'.
VERBOSE: [tst01sp16]: [[xScheduledTask]SiteProvisioningTask] Task 'Mitt Skap Site Provisioning' found in '\'. Retrieving settings, first action, first trigger and repetition settings.
VERBOSE: [tst01sp16]: [[xScheduledTask]SiteProvisioningTask] Detected schedule type 'Daily' for first trigger.
VERBOSE: [tst01sp16]: [[xScheduledTask]SiteProvisioningTask] Current scheduled task values retrieved.
VERBOSE: [tst01sp16]: [[xScheduledTask]SiteProvisioningTask] Testing DSC parameter state.
VERBOSE: [tst01sp16]: LCM: [ End Test ] [[xScheduledTask]SiteProvisioningTask] False in 0.5470 seconds.
VERBOSE: [tst01sp16]: LCM: [ End Resource ] [[xScheduledTask]SiteProvisioningTask]
VERBOSE: [tst01sp16]: LCM: [ Start Resource ] [[xScheduledTask]DatabaseDistributionTask]
VERBOSE: [tst01sp16]: LCM: [ Start Test ] [[xScheduledTask]DatabaseDistributionTask]
VERBOSE: [tst01sp16]: [[xScheduledTask]DatabaseDistributionTask] Testing scheduled task 'Mitt Skap DatabaseDistributing' in '\'.
VERBOSE: [tst01sp16]: [[xScheduledTask]DatabaseDistributionTask] Getting scheduled task 'Mitt Skap DatabaseDistributing' in '\'.
VERBOSE: [tst01sp16]: [[xScheduledTask]DatabaseDistributionTask] Task 'Mitt Skap DatabaseDistributing' found in '\'. Retrieving settings, first action, first trigger and repetition settings.
VERBOSE: [tst01sp16]: [[xScheduledTask]DatabaseDistributionTask] Detected schedule type 'Daily' for first trigger.
VERBOSE: [tst01sp16]: [[xScheduledTask]DatabaseDistributionTask] Current scheduled task values retrieved.
VERBOSE: [tst01sp16]: [[xScheduledTask]DatabaseDistributionTask] Testing DSC parameter state.
VERBOSE: [tst01sp16]: LCM: [ End Test ] [[xScheduledTask]DatabaseDistributionTask] False in 0.5320 seconds.
VERBOSE: [tst01sp16]: LCM: [ End Resource ] [[xScheduledTask]DatabaseDistributionTask]
The DSC configuration that is using the resource (as detailed as possible):
xScheduledTask SiteCreationTask
{
TaskName = 'Mitt Skap Personal Site Creation'
ActionExecutable = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe"
ActionArguments = "-Command `"& '.\PersonalSiteCreation.ps1' -mysiteurl 'https://$siteCollectionHostNameMinerva/sites/my' -pathcsv '$mittSkapAccountsCsvUrl'`""
ActionWorkingPath = "$MittSkapLocalFolder"
ScheduleType = "Daily"
StartTime = "4:40"
ExecuteAsCredential = $SPBatchCredential
RunLevel = 'Highest'
PsDscRunAsCredential = $SPBatchCredential
}
xScheduledTask SiteProvisioningTask
{
TaskName = 'Mitt Skap Site Provisioning'
ActionExecutable = "$MittSkapLocalFolder\MyCabinetJob\MyCabinet.Job.exe"
ActionWorkingPath = "$MittSkapLocalFolder\MyCabinetJob"
ScheduleType = "Daily"
StartTime = "5:00"
ExecuteAsCredential = $SPBatchCredential
RunLevel = 'Highest'
PsDscRunAsCredential = $SPBatchCredential
}
xScheduledTask DatabaseDistributionTask
{
TaskName = "Mitt Skap DatabaseDistributing"
ActionExecutable = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe"
ActionArguments = "-Command `"& '.\DistributingDatabases.ps1'`""
ActionWorkingPath = "$MittSkapLocalFolder\Logs"
ScheduleType = "Daily"
StartTime = "5:20"
ExecuteAsCredential = $SPBatchCredential
RunLevel = 'Highest'
PsDscRunAsCredential = $SPBatchCredential
}
Version of the Operating System and PowerShell the DSC Target Node is running: Win 2016, PS 5.1 Version of the DSC module you're using, or 'dev' if you're using current dev branch: 4.0.0.0
Hi @shurick81 - to help me try and repl the issue, could you let me know they type of credential you're using for $SPBatchCredential
(e.g. is it a domain cred, local Admin cred etc?)
Also, is it possible for you to try something for me? If possible could you modify the resource on your machine temporarily to allow it to output some more verbose logging?
If you're happy to try this could you open the Modules\xComputerManagement\DSCResources\MSFT_xScheduledTask\MSFT_xScheduledTask.psm1 file and find the line:
return Test-DscParameterState -CurrentValues $currentValues -DesiredValues $desiredValues
And then add -Verbose
to the end of it:
return Test-DscParameterState -CurrentValues $currentValues -DesiredValues $desiredValues -Verbose
Then when you run the Start-DscConfiguration again it should tell us which parameter is not matching. You could post the log output here but make sure you sanitize it as it COULD contain sensitive info.
Hello @PlagueHO, thank you for helping me out. The credential is domain. I guess when I change MSFT_xScheduledTask.psm1
I should do it on target node, not on the one admin node where I run Start-DscConfiguration
, is that correct?
Hi @shurick81 , that is correct. Thank you for helping me look into this one.
@PlagueHO - I have the same issue. When supplying a credential with the username in UPN or pre-UPN format it causes a failure. Thanks for the heads up on the -verbose for troubleshooting. Here is my relevant output with sensitive data altered:
[[xScheduledTask]Scheduled-Tasks-Informa-Extract] NOTMATCH: Value (type 'String') for property 'ExecuteAsCredential' does not match. Current state is 'Username' and desired state is '[email protected]'."},
[[xScheduledTask]Scheduled-Tasks-Informa-Extract] NOTMATCH: Value (type 'String') for property 'ExecuteAsCredential' does not match. Current state is 'Username' and desired state is 'Domain\Username'."},
We have the same issue:
[[xScheduledTask]xScheduledTaskWash] NOTMATCH: PSCredential username mismatch. Current state is and desired state is yolo\Yolo_App_ScheduleTask"}, [[xScheduledTask]xScheduledTaskWash] NOTMATCH: PSCredential username mismatch. Current state is Dev_App_ScheduleTask and desired state is yolo\Yolo_App_ScheduleTask"}, [[xScheduledTask]xScheduledTaskWash] NOTMATCH: Type mismatch for property 'ExecuteAsCredential' Current state type is 'String' and desired type is 'PSCredential'"},
Seems related to #200