Skip to content

Get-MgGraphAllData

SYNOPSIS

Retrieve all data from a Microsoft Graph API response, including paginated results.

SYNTAX

Get-MgGraphAllData [-GraphData] <Hashtable> [-AsPSCustomObject] [<CommonParameters>]

DESCRIPTION

The `Get-MgGraphAllData` function retrieves all data from a Microsoft Graph API response, including paginated results. It processes the initial response and follows the `@odata.nextLink` property to fetch additional data until all records are collected. The function can return the data as a raw array or as a collection of PSCustomObjects.

EXAMPLES

EXAMPLE 1

$GraphResponse = Invoke-GraphRequest -Method GET -Uri "https://graph.microsoft.com/v1.0/users"

PS C:\> Get-MgGraphAllData -GraphData $GraphResponse Retrieves all user data from the Microsoft Graph API, including paginated results.

EXAMPLE 2

$GraphResponse = Invoke-GraphRequest -Method GET -Uri "https://graph.microsoft.com/v1.0/groups"

PS C:\> Get-MgGraphAllData -GraphData $GraphResponse -AsPSCustomObject Retrieves all group data from the Microsoft Graph API and returns it as PSCustomObjects.

PARAMETERS

-GraphData

The initial Microsoft Graph API response containing the data and the `@odata.nextLink` property for pagination.

Type: Hashtable
Parameter Sets: (All)
Aliases:

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

-AsPSCustomObject

A switch to indicate that the data should be returned as a collection of PSCustomObjects.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: 2
Default value: False
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