none
New Task with trigger options in powershell RRS feed

  • Question

  • Hello, i am trying to create a new task but i am not able to configure the advanced options like:

    - Trigger options: Repeat task every *** for a duration of *** 

    I know i have to use the "-RepetitionDuration & -RepetitionInterval' but whenever is use the following input:
    -RepetitionInterval  (New-TimeSpan -Minutes 30)

    I get an error:

    New-ScheduledTaskTrigger : Parameter set cannot be resolved using the specified named parameters.

    At line:9 char:20

    +         $trigger = New-ScheduledTaskTrigger -Daily -At 12:00 -RepetitionDuration ...

    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        + CategoryInfo          : InvalidArgument: (:) [New-ScheduledTaskTrigger], ParameterBindingException

        + FullyQualifiedErrorId : AmbiguousParameterSet,New-ScheduledTaskTrigger

    What should i type to get these triggers to work?


    • Edited by Remco V Thursday, October 2, 2014 8:41 AM
    Thursday, October 2, 2014 8:40 AM

Answers

All replies

  • What was it that you typed?

    Do you understand what the error message means?  Do you know what a ParameterSet is?

    Have you to use help for the CmdLet?

    Remember that we cannot see your screen.

    http://technet.microsoft.com/en-us/library/jj649821.aspx


    ¯\_(ツ)_/¯

    Thursday, October 2, 2014 12:33 PM
  • A little hint.

    When typing a command use auto-completion to find parameters.  If you start with:

    New-ScheduledTaskTrigger -Daily -<tab>

    You will be shown only the parameters that can be used once you have chosen parameter.  This is why it is so important to actually take the time to learn PowerShell.  90% of all questions are a result of not knowing how to use help and not knowing the first thing about PowerShell.  SAve yourself a lot of headaches and study the system.  You will be surprised at how easy it is to solve these issues by yourself.


    ¯\_(ツ)_/¯

    Thursday, October 2, 2014 12:39 PM
  • Thanks for your reply, I am fairly new with using advanced powershell scripting and learning on the go.
    The $RepDuration/$RepInterval parameters does not seem to be the right one, but i can not find any information on what the proper parameters are.
    The script i am using:

    $taskName = "Task01"
    $TaskPath = "\CustomerA\"
    $RepDuration = (New-Timespan -Minutes 5)
    $Repinterval = (New-TimeSpan -Minutes 1)

    $argument = "C:\ScheduledJob.ps1 -subscriptionID 'CustomerABlabla'"
    $Start = "C:\Scripts"
    $action = New-ScheduledTaskAction -Execute "Powershell" -Argument $argument -WorkingDirectory $Start   
    $trigger = New-ScheduledTaskTrigger -Daily -At 12:00 -RepetitionDuration $RepDuration -RepetitionInterval $Repinterval
      
    $inputObject = New-ScheduledTask -Action $action -Trigger $trigger -Settings $settings
    Register-ScheduledTask -TaskName $taskName -TaskPath $TaskPath -InputObject $inputObject

    Thursday, October 2, 2014 1:09 PM
  • As posted the error is telling you the answer.  YOu need to do what I posted to see the available parameters.

    Words starting in a $ are not parameters they are variables.

    Please 0review the help for the command and the basics of PowerShell.

    http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx

    You can start by learning how to use help by typing: "HELP HELP" and read all of the instructions.

    If you use command completion as I posted you would not be stuck.


    ¯\_(ツ)_/¯

    Thursday, October 2, 2014 1:26 PM
  • This is not a useful or constructive reply.  If you looked at the CmdLet you would that the original poster is calling it with the correct parameters...  

    This seems to be some kind of restriction with trigger creation that I am also running into.

    Tuesday, October 13, 2015 12:32 PM
  • This is not a useful or constructive reply.  If you looked at the CmdLet you would that the original poster is calling it with the correct parameters...  

    This seems to be some kind of restriction with trigger creation that I am also running into.

    Again - the parameters are not valid for an parameter set.  That is what the error is saying not me.  If you have an issue please start your oown topic as this one has been marked answered and is closed.

    Also look at the error and try to understand what it means:

    "New-ScheduledTaskTrigger : Parameter set cannot be resolved using the specified named parameters."

    Look up and try to understand what a parameter set is.


    \_(ツ)_/

    Tuesday, October 13, 2015 4:11 PM
  • This is not a useful or constructive reply.  If you looked at the CmdLet you would that the original poster is calling it with the correct parameters...  

    This seems to be some kind of restriction with trigger creation that I am also running into.

    Again - the parameters are not valid for an parameter set.  That is what the error is saying not me.  If you have an issue please start your oown topic as this one has been marked answered and is closed.

    Also look at the error and try to understand what it means:

    "New-ScheduledTaskTrigger : Parameter set cannot be resolved using the specified named parameters."

    Look up and try to understand what a parameter set is.


    \_(ツ)_/

      The poster is asking for help and all he gets from jrv Consultant is a load of smart-arse crap ... absolute d***head.
    Wednesday, May 30, 2018 1:30 AM
  • Question has been answered and does not need off-topic commentary.


    \_(ツ)_/

    Wednesday, May 30, 2018 1:45 AM