Closed Zuldan closed 7 years ago
Oh, wow. I didn't try 2016 Core ever never. Let me check.... Do you know is it fine with 2012R2 Core?
@guitarrapc yes on 2012R2 core it works fine.
@guitarrapc some more info. It has something to do with PsDscRunAsCredential. When I remove PsDscRunAsCredential then the error does not appear (but then the scheduled task does not get created).
However, PsDscRunAsCredential is not a Resource matter. If so, then it would be PSDSC itself bug.
@guitarrapc it may very well be a bug in DSC or maybe something in my environment. Are you seeing the same problem in 2016 Core when PsDscRunAsCredential is used?
@Zuldan Issue not reproduced on my Test. I've tested on AzureVM for Windows Server 2016 Core with your configuration, PsDscRunAsCredential is in use.
#Windows Server 2016 Core
$credential = Get-Credential
configuration Hoge
{
Import-DscResource -ModuleName GraniResource -Name Grani_ScheduleTask
Node localhost
{
cScheduleTask ClearTempDirectoriesScheduledTask
{
Ensure = 'Present'
PsDscRunAsCredential = $credential
TaskName = 'Clear Temp'
Runlevel = 'Highest'
Compatibility = 'Win8'
Hidden = $False
Disable = $False
Execute = 'powershell.exe'
Argument = "-NoProfile -Command `"Remove-Item -Path 'C:\Windows\Temp\*' -Recurse -Exclude 'GuestIndexData.zip' -Force -ErrorAction SilentlyContinue;Remove-Item -Path 'C:\Windows\System32\Configuration\ConfigurationStatus\*' -Include @('*.mof','*.json') -Force -ErrorAction SilentlyContinue;Remove-Item -Path 'C:\Windows\logs\cbs\*' -Recurse -Force -ErrorAction SilentlyContinue`""
ScheduledAt = [datetime](New-TimeSpan -Hours 05 -Minutes (Get-Random -Maximum 119)).ToString("hh\:mm\:ss")
Daily = $True
}
}
}
$configurationData = @{
AllNodes = @(
@{
NodeName = 'localhost'
PSDscAllowPlainTextPassword = $true
}
)
}
Hoge -ConfigurationData $configurationData
Creation debug log.
VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' =
SendConfigurationApply,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' =
root/Microsoft/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer DSCTEST with user sid S-1-5-21-4171373052-2546924736-3125845430-500.
VERBOSE: [DSCTEST]: LCM: [ Start Set ]
DEBUG: [DSCTEST]: [DSCEngine]
namespace Grani_ScheduleTask
{
public enum EnsureType
{
Present,
Absent
}
}
DEBUG: [DSCTEST]: [DSCEngine]
namespace Grani_ScheduleTask
{
public enum ScheduledParameterType
{
Root,
Actions,
Principal,
Settings,
Triggers
}
}
DEBUG: [DSCTEST]: [DSCEngine]
namespace Grani_ScheduleTask
{
public enum ScheduledTaskPropertyType
{
TaskName,
Description,
Execute,
Argument,
WorkingDirectory,
Credential,
RunLevel,
Compatibility,
ExecutionTimeLimit,
Hidden,
Disable,
ScheduledAt,
RepetitionIntervalTimeSpanString,
RepetitionDurationTimeSpanString,
Daily,
Once,
AtSartup,
AtLogOn,
AtLogOnUserId
}
}
VERBOSE: [DSCTEST]: LCM: [ Start Resource ] [[cScheduleTask]ClearTempDirectoriesScheduledTask]
VERBOSE: [DSCTEST]: LCM: [ Start Test ] [[cScheduleTask]ClearTempDirectoriesScheduledTask]
DEBUG: [DSCTEST]: [[cScheduleTask]ClearTempDirectoriesScheduledTask]
namespace Grani_ScheduleTask
{
public enum EnsureType
{
Present,
Absent
}
}
DEBUG: [DSCTEST]: [[cScheduleTask]ClearTempDirectoriesScheduledTask]
namespace Grani_ScheduleTask
{
public enum ScheduledParameterType
{
Root,
Actions,
Principal,
Settings,
Triggers
}
}
DEBUG: [DSCTEST]: [[cScheduleTask]ClearTempDirectoriesScheduledTask]
namespace Grani_ScheduleTask
{
public enum ScheduledTaskPropertyType
{
TaskName,
Description,
Execute,
Argument,
WorkingDirectory,
Credential,
RunLevel,
Compatibility,
ExecutionTimeLimit,
Hidden,
Disable,
ScheduledAt,
RepetitionIntervalTimeSpanString,
RepetitionDurationTimeSpanString,
Daily,
Once,
AtSartup,
AtLogOn,
AtLogOnUserId
}
}
VERBOSE: [DSCTEST]: [[cScheduleTask]ClearTempDirectoriesScheduledTask] False
DEBUG: [DSCTEST]: [[cScheduleTask]ClearTempDirectoriesScheduledTask] Checking TaskPath is
exists with : \
DEBUG: [DSCTEST]: [[cScheduleTask]ClearTempDirectoriesScheduledTask] TaskPath : False ()
VERBOSE: [DSCTEST]: LCM: [ End Test ] [[cScheduleTask]ClearTempDirectoriesScheduledTask] in 7.3760 seconds.
VERBOSE: [DSCTEST]: LCM: [ Start Set ] [[cScheduleTask]ClearTempDirectoriesScheduledTask]
VERBOSE: [DSCTEST]: [[cScheduleTask]ClearTempDirectoriesScheduledTask] Ensure detected as
Present. Setting ScheduledTask for TaskPath '\', TaskName 'Clear Temp'.
DEBUG: [DSCTEST]: [[cScheduleTask]ClearTempDirectoriesScheduledTask] Setting Action Execute
: 'powershell.exe', Argument : '-NoProfile -Command "Remove-Item -Path 'C:\Windows\Temp\*' -Recurse -Exclude
'GuestIndexData.zip' -Force -ErrorAction SilentlyContinue;Remove-Item -Path
'C:\Windows\System32\Configuration\ConfigurationStatus\*' -Include @('*.mof','*.json') -Force -ErrorAction
SilentlyContinue;Remove-Item -Path 'C:\Windows\logs\cbs\*' -Recurse -Force -ErrorAction SilentlyContinue"',
WorkingDirectory : ''.
DEBUG: [DSCTEST]: [[cScheduleTask]ClearTempDirectoriesScheduledTask] Setting Trigger
RepetitionIntervalTimeSpanString : '', RepetitionDurationTimeSpanString : '', ScheduledAt : 'System.DateTime[]', Daily
: 'True', Once : 'False'.
DEBUG: [DSCTEST]: [[cScheduleTask]ClearTempDirectoriesScheduledTask] Skip Credential. Using
System for Principal.
DEBUG: [DSCTEST]: [[cScheduleTask]ClearTempDirectoriesScheduledTask]
State : Ready
Actions : {MSFT_TaskExecAction}
Author :
Date :
Description :
Documentation :
Principal : MSFT_TaskPrincipal2
SecurityDescriptor :
Settings : MSFT_TaskSettings3
Source :
TaskName : Clear Temp
TaskPath : \
Triggers : {MSFT_TaskDailyTrigger}
URI : \Clear Temp
Version :
PSComputerName :
CimClass : Root/Microsoft/Windows/TaskScheduler:MSFT_ScheduledTask
CimInstanceProperties : {Actions, Author, Date, Description...}
CimSystemProperties : Microsoft.Management.Infrastructure.CimSystemProperties
VERBOSE: [DSCTEST]: LCM: [ End Set ] [[cScheduleTask]ClearTempDirectoriesScheduledTask] in 1.0150 seconds.
VERBOSE: [DSCTEST]: LCM: [ End Resource ] [[cScheduleTask]ClearTempDirectoriesScheduledTask]
VERBOSE: [DSCTEST]: LCM: [ End Set ]
VERBOSE: [DSCTEST]: LCM: [ End Set ] in 13.2500 seconds.
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 13.676 seconds
Here's Test result
Test-DscConfiguration -Detailed
PSComputerName ResourcesInDesiredState ResourcesNotInDesiredState InDesiredState
localhost {[cScheduleTask]ClearTempDi... True
Actual settings.
```powershell
Get-ScheduledTask -TaskName 'Clear Temp'
TaskPath TaskName State
-------- -------- -----
\ Clear Temp Ready
As test passed, next "SET" execution is successfully skipped as expected.
VERBOSE: [DSCTEST]: LCM: [ Skip Set ] [[cScheduleTask]ClearTempDirectoriesScheduledTask]
VERBOSE: [DSCTEST]: LCM: [ End Resource ] [[cScheduleTask]ClearTempDirectoriesScheduledTask]
VERBOSE: [DSCTEST]: LCM: [ End Set ]
VERBOSE: [DSCTEST]: LCM: [ End Set ] in 2.3290 seconds.
The Path I've tested was Default, means C:\
. Do you think your error message "The filename or extension is too long" relates to path?
@guitarrapc thank you for doing the testing. It's encouraging to know Core and PsDscRunAsCredential works for you.
I don't suspect it's related to path because I've even enabled long path support (https://blogs.msdn.microsoft.com/jeremykuhne/2016/07/30/net-4-6-2-and-long-paths-on-windows-10/).
I'm starting to suspect it's something to do with the certificate (long Subject name etc). Are you encrypting your MOF files like so? https://msdn.microsoft.com/en-us/powershell/dsc/securemof
@Zuldan No, I just passed credential as PlainText, it's too much annoying me to test with Azure VM for sspot.
Thanks for all your help @guitarrapc . I will try figure out what's going on. I will close this case as it doesn't have anything to do with your resource.
I'm sorry for commenting on this closed topic, but did you @Zuldan ever figure this out? I have a similar issue with FailoverClusterDsc and did not find a way of contacting you directly via gh.
I had this issue a long time ago. I can’t remember exactly what the issue was but I think it had something to do with the DSC file being too big (the one cScheduledTask was used in), as in there were too many configurations in a single file. Sorry I couldn’t be much more help.
On Windows 2016 Core, I receive "The filename or extension is too long" error on all configurations that use cScheduledTask.
On Windows 2016 GUI, cScheduledTask works perfectly fine using the exact same config as Core.