guitarrapc / GraniResource

PowerShell Desired State Configuration Resources for real production workload.
https://www.powershellgallery.com/packages/GraniResource
MIT License
44 stars 8 forks source link

PS 5.1 - Cannot bind argument to parameter 'ScheduledTask' because it is null #67

Closed Zuldan closed 7 years ago

Zuldan commented 7 years ago

When running cScheduledTask on Windows 2012 R2 with Powershell 5.1 (RTM) the following error appears on all cScheduledTask resources.

VERBOSE: [LABSERVER01]: LCM:  [ Start  Resource ]  [[cScheduleTask]PowershellHelpUpdateScheduledTask]
VERBOSE: [LABSERVER01]: LCM:  [ Start  Test     ]  [[cScheduleTask]PowershellHelpUpdateScheduledTask]
VERBOSE: [LABSERVER01]:                            [[cScheduleTask]PowershellHelpUpdateScheduledTask] False
Invoke-CimMethod : Cannot bind argument to parameter 'ScheduledTask' because it is null.
At C:\Test\MyScheduledTask\InvokeDSC.ps1:20 char:5
+     Invoke-CimMethod -CimSession $ServerName -Name PerformRequiredCon ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Invoke-CimMethod], CimException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,GetScheduledTask,Microsoft.Management.Infrastructure.CimCmdlets.InvokeCimMethodCommand
    + PSComputerName        : LABSERVER01
guitarrapc commented 7 years ago

Thank you for reporting. I'll check with my lab.

Zuldan commented 7 years ago

Thanks @guitarrapc. Let me know if you are able to replicate the issue.

Zuldan commented 7 years ago

My apologies. The issue was I had 3rd part scheduled task module that had -Name instead of -TaskName for Get-ScheduledTask. I've removed the module and everything is now working.

guitarrapc commented 7 years ago

Thank you for update! never mind!