Invoke-Retry¶
SYNOPSIS¶
Runs a scriptblock with a retry mechanism.
SYNTAX¶
__AllParameterSets¶
Invoke-Retry [-Run] <scriptblock> [[-Count] <int>] [[-Delay] <int>] [[-Catch] <scriptblock>]
[[-Finally] <scriptblock>] [<CommonParameters>]
ALIASES¶
This cmdlet has the following aliases, {{Insert list of aliases}}
DESCRIPTION¶
Runs a scriptblock with a retry mechanism. If the scriptblock fails, it will retry the scriptblock a number of times with a delay between each try. If a catch scriptblock is provided, it will run that scriptblock if the scriptblock fails.
EXAMPLES¶
EXAMPLE 1¶
Retry -Count 5 -Delay 5 -Run {
Invoke-RestMethod -Uri 'https://api.myip.com/'
}
Retries an API call 5 times with 5 reconds delay.
PARAMETERS¶
-Catch¶
A scriptblock to run if it fails
Type: System.Management.Automation.ScriptBlock
DefaultValue: '{}'
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: 3
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-Count¶
The number of tries to make
Type: System.Int32
DefaultValue: 3
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: 1
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-Delay¶
The delay between tries in seconds
Type: System.Int32
DefaultValue: 5
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: 2
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-Finally¶
A scriptblock to run after the scriptblock has run
Type: System.Management.Automation.ScriptBlock
DefaultValue: '{}'
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: 4
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-Run¶
The scriptblock to run
Type: System.Management.Automation.ScriptBlock
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: 0
IsRequired: true
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
CommonParameters¶
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
INPUTS¶
OUTPUTS¶
NOTES¶
RELATED LINKS¶
{{ Fill in the related links here }}