< Back

Add-PodeTimer

Sat Jan 18, 2020 7:13 pm

NAME Add-PodeTimer



SYNOPSIS

Adds a new Timer with logic to periodically invoke.





SYNTAX

Add-PodeTimer [-Name] <String> [-Interval] <Int32> [-ScriptBlock] <ScriptBlock> [[-Limit] <Int32>] [[-Skip]

<Int32>] [[-ArgumentList] <Object[]>] [-OnStart] [<CommonParameters>]





DESCRIPTION

Adds a new Timer with logic to periodically invoke, with options to only run a specific number of times.





PARAMETERS

-Name <String>

The Name of the Timer.



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Interval <Int32>

The number of seconds to periodically invoke the Timer's ScriptBlock.



Required? true

Position? 2

Default value 0

Accept pipeline input? false

Accept wildcard characters? false



-ScriptBlock <ScriptBlock>

The script for the Timer.



Required? true

Position? 3

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Limit <Int32>

The number of times the Timer should be invoked before being removed. (If 0, it will run indefinitely)



Required? false

Position? 4

Default value 0

Accept pipeline input? false

Accept wildcard characters? false



-Skip <Int32>

The number of "invokes" to skip before the Timer actually runs.



Required? false

Position? 5

Default value 0

Accept pipeline input? false

Accept wildcard characters? false



-ArgumentList <Object[]>

An array of arguments to supply to the Timer's ScriptBlock.



Required? false

Position? 6

Default value

Accept pipeline input? false

Accept wildcard characters? false



-OnStart [<SwitchParameter>]

If supplied, the timer will trigger when the server starts.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Add-PodeTimer -Name 'Hello' -Interval 10 -ScriptBlock { 'Hello, world!' | Out-Default }













-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Add-PodeTimer -Name 'RunOnce' -Interval 1 -Limit 1 -ScriptBlock { /* logic */ }













-------------------------- EXAMPLE 3 --------------------------



PS C:\\>Add-PodeTimer -Name 'RunAfter60secs' -Interval 10 -Skip 6 -ScriptBlock { /* logic */ }













-------------------------- EXAMPLE 4 --------------------------



PS C:\\>Add-PodeTimer -Name 'Args' -Interval 2 -ScriptBlock { /* logic */ } -ArgumentList 'arg1', 'arg2'















RELATED LINKS