-
Notifications
You must be signed in to change notification settings - Fork 8
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
[DSCPlatformIssue]New-ScheduledTaskTrigger not compatible with PowerShell 4 and 5 #58
Comments
Thank you for reporting. I knew there are Bug with New-ScheduledTaskTrigger on WMF5, includes Windows 10, with Unfortunately your proposal, and also link to the powershell.org, PS C:\Users\> $trigger = New-JobTrigger -Daily -At 11AM | gm
PS C:\Users\> $action = New-ScheduledTaskAction -Execute powershell.exe
PS C:\Users\> New-ScheduledTask -Action $action -Trigger $trigger
New-ScheduledTask : Cannot process argument transformation on parameter 'Trigger'. Cannot convert the "bool
Equals(System.Object obj)" value of type "Microsoft.PowerShell.Commands.MemberDefinition" to type
"Microsoft.Management.Infrastructure.CimInstance".
At line:1 char:44
+ New-ScheduledTask -Action $action -Trigger $trigger
+ ~~~~~~~~
+ CategoryInfo : InvalidData: (:) [New-ScheduledTask], ParameterBindingArgumentTransformationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,New-ScheduledTask Future PlanSo what the option? Yes I have idea with, however this idea is completely through away PowerShell ScheduledTask Module and shift all logic to C#. I already implement for C#, works perfect in production, but not yet ported to PowerShell. QuestionDo you experience same issue on Windows Server 2012 R2 WMF4 and WMF5 RTM? I have tested with Windows Server 2012 R2 + WMF4 (w/Nov update) without any issue but not yet for other environment. I just want to know whether this issue is limited or give up with PowerShell ScheduledTask Module, sigh.... :( |
I quickly tested on a 2012R2 server with the following $PSVersionTable and Name Value PSVersion 4.0 2016-03-09 18:56 GMT+01:00 Ikiru Yoshizaki [email protected]:
|
Thank you cveld, It might be better through PowerShell away and use C# Implementation. I will do it, please wait a moment. |
I am getting the following exception when trying out the cScheduleTask resource:
Method "NewTriggerByDaily" not found + CategoryInfo : ObjectNotFound: (PS_ScheduledTask:) [], CimException + FullyQualifiedErrorId : HRESULT 0x80041002,New-ScheduledTaskTrigger + PSComputerName : localhost
This is on a Windows 7 laptop with PowerShell 4 and on a Windows 10 laptop with PowerShell 5 installed.
I have found the following forum discussion that seems to contain the answer:
http://powershell.org/wp/forums/topic/method-newtriggerbyonce-not-found-taskscheduler/
It looks like
New-ScheduledTaskTrigger -Daily -At '11AM'
constructions need to be replaced byNew-JobTrigger -Daily -At 11AM
.I have tested these two expressions on my test devices and both respond as expected, i.e. the first generates the exception
New-ScheduledTaskTrigger : Method "NewTriggerByDaily" not found
whereas the second replies with aJobTrigger
object.The text was updated successfully, but these errors were encountered: