Please feel free to provide feedback or file bugs here.

BUG: ScheduledTasks module broken in 1511

ICAN use New-SchedualedTaskTrigger -AtSartup without error SO THAT I can schedule tasks

Repeat issue: update win10 to 1511 and run this command in PowerShell
New-ScheduledTaskTrigger -AtStartup
New-ScheduledTaskTrigger : Method "NewTriggerByStartup" not found
At line:1 char:1
+ New-ScheduledTaskTrigger -AtStartup
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (PS_ScheduledTask:Root/Microsoft/...S_ScheduledTask) [New-ScheduledTaskTrigger], CimException
+ FullyQualifiedErrorId : HRESULT 0x80041002,New-ScheduledTaskTrigger

17 votes
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)

    We’ll send you updates on this idea

    David JonesDavid Jones shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    7 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • Michel BoivinMichel Boivin commented  ·   ·  Flag as inappropriate

        Ran into the exact same issue on a few systems. Running "mofcomp C:\Windows\System32\wbem\SchedProv.mof" does resolve the problem.

        I'm calling the New-ScheduledTaskTrigger cmdlet as part of the installation
        process of an application I'm developing. I'm concerned about adverse effects
        of calling mofcomp without the user being aware. Should mofcomp be reserved to
        sys admins or it's a failure safe operation I can add to my installation
        process without risk?

      • Mathieu BuissonMathieu Buisson commented  ·   ·  Flag as inappropriate

        Well done David !

        After running the command : mofcomp C:\Windows\System32\wbem\SchedProv.mof ,
        I have no problem anymore with the parameter -Once as well.

        Also, it made additional methods visible for the PS_ScheduledTask CIM class :

        PS C:\> $PS_ScheduledTaskClass = Get-CimClass -Namespace root/Microsoft/Windows/TaskScheduler -ClassName PS_Sched
        uledTask
        PS C:\> $PS_ScheduledTaskClass.CimClassMethods.Name
        RegisterByObject
        RegisterByPrincipal
        RegisterByUser
        RegisterByXml
        NewActionByExec
        NewPrincipalByGroup
        NewPrincipalByUser
        NewSettings
        StartByObject
        StartByPath
        StopByObject
        StopByPath
        SetByObject
        SetByPrincipal
        SetByUser
        GetInfoByName
        GetInfoByObject
        New
        ExportByName
        ExportByObject
        EnableByName
        EnableByObject
        DisableByName
        DisableByObject
        NewTriggerByDaily
        NewTriggerByOnce
        NewTriggerByLogon
        NewTriggerByStartup
        NewTriggerByWeekly

      • Mathieu BuissonMathieu Buisson commented  ·   ·  Flag as inappropriate

        Same error when using the -Once parameter of New-ScheduledTaskTrigger .

        For example :

        PS C:\> New-ScheduledTaskTrigger -Once -At "18:00"
        New-ScheduledTaskTrigger : Method "NewTriggerByOnce" not found
        At line:1 char:1
        + New-ScheduledTaskTrigger -Once -At "18:00"
        + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo : ObjectNotFound: (PS_ScheduledTask:Root/Microsoft/...S_ScheduledTask) [New-Schedul
        edTaskTrigger], CimException
        + FullyQualifiedErrorId : HRESULT 0x80041002,New-ScheduledTaskTrigger

        I am also using build 1511 of Windows 10.
        PS C:\> $PSVersionTable

        Name Value
        ---- -----
        PSVersion 5.0.10586.63
        PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
        BuildVersion 10.0.10586.63
        CLRVersion 4.0.30319.42000
        WSManStackVersion 3.0
        PSRemotingProtocolVersion 2.3
        SerializationVersion 1.1.0.1

        This has been encountered by several people, here for example :
        http://powershell.org/wp/forums/topic/method-newtriggerbyonce-not-found/

        This may be interesting information to troubleshoot :

        PS C:\> $error[0].categoryinfo

        Category : ObjectNotFound
        Activity : New-ScheduledTaskTrigger
        Reason : CimException
        TargetName : PS_ScheduledTask
        TargetType : Root/Microsoft/Windows/TaskScheduler/PS_ScheduledTask

        It seems the cmdlet cannot find a method called "NewTriggerByOnce" of the CIM class PS_ScheduledTask.

        PS C:\> $PS_ScheduledTaskClass = Get-CimClass -Namespace root/Microsoft/Windows/TaskScheduler -ClassName PS_ScheduledTask

        PS C:\> $PS_ScheduledTaskClass.CimClassMethods.Name
        RegisterByObject
        RegisterByPrincipal
        RegisterByUser
        RegisterByXml
        NewActionByExec
        NewPrincipalByGroup
        NewPrincipalByUser
        NewSettings
        StartByObject
        StartByPath
        StopByObject
        StopByPath
        SetByObject
        SetByPrincipal
        SetByUser
        GetInfoByName
        GetInfoByObject
        New
        ExportByName
        ExportByObject
        EnableByName
        EnableByObject
        DisableByName
        DisableByObject

        Indeed, the method is not visible here.

        PS C:\> Get-CimClass -MethodName "*TriggerByOnce*"

        --> Nothing.
        So I can't see any CIM class which has a method with a name similar to what the cmdlet is looking for.

      • David JonesDavid Jones commented  ·   ·  Flag as inappropriate

        In summary. from an elevated prompt run

        mofcomp C:\Windows\System32\wbem\SchedProv.mof

      • David JonesDavid Jones commented  ·   ·  Flag as inappropriate

        workarround:
        PS C:\WINDOWS\system32> New-ScheduledTaskTrigger -AtStartup
        New-ScheduledTaskTrigger : Method "NewTriggerByStartup" not found
        At line:1 char:1
        + New-ScheduledTaskTrigger -AtStartup
        + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo : ObjectNotFound: (PS_ScheduledTask:Root/Microsoft/...S_ScheduledTask) [New-ScheduledTaskT
        rigger], CimException
        + FullyQualifiedErrorId : HRESULT 0x80041002,New-ScheduledTaskTrigger

        PS C:\WINDOWS\system32> mofcomp C:\Windows\System32\wbem\SchedProv.mof
        Microsoft (R) MOF Compiler Version 10.0.10586.0
        Copyright (c) Microsoft Corp. 1997-2006. All rights reserved.
        Parsing MOF file: C:\Windows\System32\wbem\SchedProv.mof
        MOF file has been successfully parsed
        Storing data in the repository...
        Done!
        PS C:\WINDOWS\system32> New-ScheduledTaskTrigger -AtStartup

        Enabled : True
        EndBoundary :
        ExecutionTimeLimit :
        Id :
        Repetition :
        StartBoundary :
        Delay :
        PSComputerName :

        PS C:\WINDOWS\system32>

      Feedback and Knowledge Base