Method "NewTriggerByOnce" not found

Welcome Forums General PowerShell Q&A Method "NewTriggerByOnce" not found

This topic contains 6 replies, has 6 voices, and was last updated by

 
Participant
2 years, 11 months ago.

  • Author
    Posts
  • #31430

    Participant
    Points: 0
    Rank: Member

    Here is what I'm trying to do (Add trigger to scheduled task on remote machine):

    Invoke-Command -ComputerName BETA -ScriptBlock {Set-ScheduledTask -TaskPath '\Monitor\' -TaskNam
    e 'Off' -Trigger (New-ScheduledTaskTrigger -At 16:40 -Once)}

    which results into:

    Method "NewTriggerByOnce" not found
        + CategoryInfo          : ObjectNotFound: (PS_ScheduledTask:Root/Microsoft/...S_ScheduledTask) [New-ScheduledTaskT
       rigger], CimException
        + FullyQualifiedErrorId : HRESULT 0x80041002,New-ScheduledTaskTrigger
        + PSComputerName        : BETA
    
    Cannot validate argument on parameter 'Trigger'. The argument is null or empty. Provide an argument that is not null or
     empty, and then try the command again.
        + CategoryInfo          : InvalidData: (:) [Set-ScheduledTask], ParameterBindingValidationException
        + FullyQualifiedErrorId : ParameterArgumentValidationError,Set-ScheduledTask
        + PSComputerName        : BETA

    wondering may be someone have same issue?

  • #31446

    Participant
    Points: 0
    Rank: Member

    What version of Windows and PowerShell are you using on the local and remote machines?

    I've reproduced your error on a windows 10 machine
    PS> New-ScheduledTaskTrigger -At 16:40 -Once
    New-ScheduledTaskTrigger : Method "NewTriggerByOnce" not found
    At line:1 char:1
    + New-ScheduledTaskTrigger -At 16:40 -Once
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (PS_ScheduledTask:Root/Microsoft/...S_ScheduledTask) [New-ScheduledTaskT
    rigger], CimException
    + FullyQualifiedErrorId : HRESULT 0x80041002,New-ScheduledTaskTrigger

    Using the production preview of WMF 5.0 on Windows Server 2012 R2 command works and I can create the trigger.

    I've also found a difference between the commands on the 2 versions of PowerShell.

    I'll investigate this further. Something isn't right somewhere

  • #31452

    Participant
    Points: 0
    Rank: Member

    Oh, it seems that you are right, I just have tried that script from home laptop to work pc all works (both have Windows 10) but machine that I was tried before have Windows 10 Insider Preview, so probably there is some kind of regression, hope that it will not happen later on in normal Windows 10

  • #33329

    Participant
    Points: 0
    Rank: Member

    Running regular Windows 10 with the following PS Version and still getting the same type of error when trying to create a daily trigger. Any updates?

    Name Value
    —- —–
    PSVersion 5.0.10586.0
    PSCompatibleVersions {1.0, 2.0, 3.
    BuildVersion 10.0.10586.0
    CLRVersion 4.0.30319.420
    WSManStackVersion 3.0
    PSRemotingProtocolVersion 2.3
    SerializationVersion 1.1.0.1

  • #33409

    Participant
    Points: 0
    Rank: Member
  • #33999

    Participant
    Points: 4
    Rank: Member

    found a fix and posted it user voice.
    From an elevated prompt (PowerShell or CMD)
    mofcomp C:\Windows\System32\wbem\SchedProv.mof

    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>
    
  • #37961

    Participant
    Points: 0
    Rank: Member

    Thank you David.

    Recompiling SchedProv.mof fixed my error when trying to create a scheduled task with a daily trigger: New-ScheduledTaskTrigger : Method "NewTriggerByDaily" not found

    I have a Win 8.1 to Win 10 upgraded machine with
    PSVersion 5.0.10586.122
    PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
    BuildVersion 10.0.10586.122
    CLRVersion 4.0.30319.42000
    WSManStackVersion 3.0
    PSRemotingProtocolVersion 2.3
    SerializationVersion 1.1.0.1

The topic ‘Method "NewTriggerByOnce" not found’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort