< Back

Invoke-ScriptBlockWithRetries

Sat Jan 18, 2020 9:44 pm

NAME Invoke-ScriptBlockWithRetries



SYNOPSIS

Calls a script block with retries





SYNTAX

Invoke-ScriptBlockWithRetries [-ScriptBlock] <ScriptBlock> [[-RetryCount] <Int32>] [[-TimeoutInSecs] <Int32>]

[[-SuccessMessage] <String>] [[-FailureMessage] <String>] [<CommonParameters>]





DESCRIPTION

The Invoke-ScriptBlockWithRetries function calls a script block, retrying when an exception is thrown





PARAMETERS

-ScriptBlock <ScriptBlock>

The script block to call.



Required? true

Position? 1

Default value

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



-RetryCount <Int32>

The maximum number of times to retry the script block



Required? false

Position? 2

Default value 3

Accept pipeline input? false

Accept wildcard characters? false



-TimeoutInSecs <Int32>

The time in seconds benteen retries



Required? false

Position? 3

Default value 30

Accept pipeline input? false

Accept wildcard characters? false



-SuccessMessage <String>

The message to print when the script block was successfully execited



Required? false

Position? 4

Default value

Accept pipeline input? false

Accept wildcard characters? false



-FailureMessage <String>

The message to print when the script block was unsuccessfully execited



Required? false

Position? 5

Default value

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

The output of the last successful script block execution.







RELATED LINKS