# Invoke-MtGraphRequest

Enhanced version of Invoke-MgGraphRequest that supports paging, batching and caching.

Source: https://maester.dev/docs/commands/Invoke-MtGraphRequest

## SYNOPSIS

Enhanced version of Invoke-MgGraphRequest that supports paging, batching and caching.

## SYNTAX

```powershell
Invoke-MtGraphRequest [-RelativeUri] <String[]> [-UniqueId <String[]>] [-Select <String[]>] [-Filter <String>]
 [-QueryParameters <Hashtable>] [-ApiVersion <String>] [-Method <String>] [-Body <String>]
 [-ConsistencyLevel <String>] [-DisablePaging] [-DisableBatching] [-BatchSize <Int32>] [-GraphBaseUri <Uri>]
 [-DisableCache] [-OutputType <String>] [-ProgressAction <ActionPreference>] [<CommonParameters>]
```

## DESCRIPTION

The version of Invoke-Graph request supports
* Filter, Select and Unique IDs as parameters
* Automatic paging if Graph returns a nextLink
* Batching of requests to Graph if multiple requests are piped through
* Caching of results for the duration of the session
* Ability to skip cache and go directly to Graph
* Specify consistency level as a parameter

:::note
Note: Batch requests don't support caching.
:::

In a batch, a request that Graph throttles (429, 503 or 504) is sent again after the wait Graph asks for, up to
three times.
A request for an object that does not exist (404) returns nothing.
Any other failed request in the
batch throws an error.

## EXAMPLES

### EXAMPLE 1

```powershell
Invoke-MtGraph -RelativeUri "users" -Filter "displayName eq 'John Doe'" -Select "displayName"
```

Get all users with a display name of "John Doe" and return the first 10 results.

## PARAMETERS

### -RelativeUri

Graph endpoint such as "users".

```yaml
Type: String[]
Parameter Sets: (All)
Aliases:

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

### -UniqueId

Specifies unique Id(s) for the URI endpoint.
For example, users endpoint accepts Id or UPN.

```yaml
Type: String[]
Parameter Sets: (All)
Aliases:

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

### -Select

Filters properties (columns).

```yaml
Type: String[]
Parameter Sets: (All)
Aliases:

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

### -Filter

Filters results (rows).
https://docs.microsoft.com/graph/query-parameters#filter-parameter

```yaml
Type: String
Parameter Sets: (All)
Aliases:

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

### -QueryParameters

Parameters such as "$top".

```yaml
Type: Hashtable
Parameter Sets: (All)
Aliases:

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

### -ApiVersion

API Version.

```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: V1.0
Accept pipeline input: False
Accept wildcard characters: False
```

### -Method

HTTP Method to use for the request.

```yaml
Type: String
Parameter Sets: (All)
Aliases:

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

### -Body

Body for POST requests.

```yaml
Type: String
Parameter Sets: (All)
Aliases:

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

### -ConsistencyLevel

Specifies consistency level.

```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: Eventual
Accept pipeline input: False
Accept wildcard characters: False
```

### -DisablePaging

Only return first page of results.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```

### -DisableBatching

Force individual requests to MS Graph.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```

### -BatchSize

Specify Batch size.

```yaml
Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: 20
Accept pipeline input: False
Accept wildcard characters: False
```

### -GraphBaseUri

Base URL for Microsoft Graph API.

```yaml
Type: Uri
Parameter Sets: (All)
Aliases:

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

### -DisableCache

Specify if this request should skip cache and go directly to Graph.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```

### -OutputType

The shape of the response.
Keep the default (PSObject) unless your code cannot work without another type.
Responses are cached per output type, so a request for Hashtable or PSCustomObject misses the response
that other checks already cached as PSObject and makes its own call to Microsoft Graph.

```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: PSObject
Accept pipeline input: False
Accept wildcard characters: False
```

### -ProgressAction

Determines how PowerShell responds to progress updates generated by a script, cmdlet, or provider, such as the progress bars generated by Write-Progress.

```yaml
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
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](http://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

## OUTPUTS

## NOTES

## RELATED LINKS

[https://maester.dev/docs/commands/Invoke-MtGraphRequest](https://maester.dev/docs/commands/Invoke-MtGraphRequest)
