-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Jiri Formacek edited this page Jul 4, 2026
·
1 revision
PowerShell module for Microsoft Graph API operations with practical defaults for automation.
- Access token acquisition via AadAuthenticationFactory
- Relative or absolute Graph URI handling
- Automatic pagination for GET queries (
@odata.nextLinktraversal) - Retry handling for throttling (HTTP 429) and other transient errors
- Graph batch request helpers (up to 20 subrequests per call)
- Large file upload via resumable upload sessions
- Optional Application Insights telemetry via AiLogger
| Module | Required | Purpose |
|---|---|---|
| AadAuthenticationFactory | Yes | Provides Get-AadToken and factory registration/lookup |
| AiLogger | No | Optional Application Insights dependency/exception logging |
Install-Module AadAuthenticationFactory
Install-Module AiLogger # optional
Install-Module GraphApiHelperWhen the module loads it initializes with these defaults:
| Setting | Default value |
|---|---|
| Factory name | graph |
| Base URI | https://graph.microsoft.com/v1.0 |
| Scope | https://graph.microsoft.com/.default |
| AI logger |
$null (disabled) |
All defaults can be changed with the Configuration commands.
# Use a factory already registered in AadAuthenticationFactory
Set-GraphAadFactory -Name 'ManagedIdentityFactory'# Delegated permissions example
Set-GraphScopes -Scopes @('User.Read', 'Mail.Read')
# Sovereign cloud
Set-GraphBaseUri -BaseUri 'https://graph.microsoft.us/v1.0'
Set-GraphScopes -Scopes 'https://graph.microsoft.us/.default'# GET with automatic pagination
$users = Get-GraphData -RequestUri '/users' -WithSelect 'id,displayName,userPrincipalName' -Top 25
# POST a new group
$body = @{
displayName = 'Finance Team'
mailEnabled = $false
mailNickname = 'finance-team'
securityEnabled = $true
} | ConvertTo-Json
Invoke-GraphWithRetry -RequestUri '/groups' -Method Post -Body $body| Page | Contents |
|---|---|
| Configuration | Set-GraphAadFactory, Set-GraphScopes, Set-GraphBaseUri, Set-GraphAiLogger |
| Data Access | Get-GraphData, Invoke-GraphWithRetry, Get-GraphAuthorizationHeader |
| URL Building | New-GraphUri |
| Batch Requests | New-GraphBatchRequest, Invoke-GraphBatch |
| Directory References | Add-GraphReference, Remove-GraphReference, Get-GraphReferenceUri |
| File Upload | Add-GraphLargeFile |
| Error Handling | ConvertFrom-GraphErrorRecord |
| National Clouds | Cloud endpoint and scope reference |
| Command Reference | Quick-reference table of all exported commands |
Configuration
Making API Calls
Directory Objects
Files
Diagnostics
Reference