Skip to main content

SYNOPSIS

Wraps Invoke-MgGraphRequest with automatic retry on HTTP 429 (throttling).

SYNTAX

Invoke-MgGraphRequestWithRetry [-Uri] <String> [[-Method] <String>] [[-Body] <Object>] [[-MaxRetries] <Int32>]
 [-ProgressAction <ActionPreference>] [<CommonParameters>]

DESCRIPTION

Manual pagination loops over large tenants can be throttled by Graph. Without a retry, the catch block typically logs a warning and continues, silently returning incomplete results. This helper retries on 429, honoring the Retry-After header when present and otherwise backing off exponentially (capped at 60s). Any non-429 error is rethrown unchanged.

EXAMPLES

PARAMETERS

-Uri

The Graph request URI.
Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Method

HTTP method (default GET).
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 2
Default value: GET
Accept pipeline input: False
Accept wildcard characters: False

-Body

Optional request body.
Type: Object
Parameter Sets: (All)
Aliases:

Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-MaxRetries

Maximum number of retry attempts on 429 (default 5).
Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: 4
Default value: 5
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

NOTES