-
Notifications
You must be signed in to change notification settings - Fork 0
Configuration
Jiri Formacek edited this page Jul 4, 2026
·
2 revisions
These commands configure module-level settings that are shared by all GraphApiHelper commands. Call them once at the start of your script before making any Graph API calls.
Sets the AadAuthenticationFactory instance to use for obtaining access tokens.
| Parameter | Type | Required | Description |
|---|---|---|---|
Name |
String |
Yes | The factory name registered with New-AadAuthenticationFactory. |
Force |
Switch |
No | Skip validation that the factory currently exists. Useful when the factory is registered later in the script. |
# Use a managed identity factory
Set-GraphAadFactory -Name 'ManagedIdentityFactory'# Use a custom factory name
Set-GraphAadFactory -Name 'MyAppFactory'# Set name before the factory is registered
Set-GraphAadFactory -Name 'FactoryRegisteredLater' -Force- When
-Forceis not specified the command throws if the factory cannot be found in the current session. - The configured factory name is stored in module scope and used by all subsequent Graph commands.
- Default factory name is
graph.
Sets the OAuth2 scopes used when requesting access tokens.
| Parameter | Type | Required | Description |
|---|---|---|---|
Scopes |
String[] |
No | One or more OAuth2 scopes. Default: 'https://graph.microsoft.com/.default'. |
# Application permissions (default)
Set-GraphScopes -Scopes 'https://graph.microsoft.com/.default'# Delegated permissions
Set-GraphScopes -Scopes @(
'https://graph.microsoft.com/User.Read',
'https://graph.microsoft.com/Mail.Read'
)# Sovereign cloud scope
Set-GraphScopes -Scopes 'https://graph.microsoft.us/.default'- The default scope is
https://graph.microsoft.com/.defaultwhich requests all application permissions granted to the identity. - For delegated scenarios ensure the authentication factory is configured for interactive or device-code flow.
Sets the base URI prepended to relative Graph paths. The URI must include the API version segment.
| Parameter | Type | Required | Description |
|---|---|---|---|
BaseUri |
String |
Yes | Full base URI including API version (e.g. https://graph.microsoft.com/v1.0). |
# Global cloud, stable version (default)
Set-GraphBaseUri -BaseUri 'https://graph.microsoft.com/v1.0'# Global cloud, beta endpoint
Set-GraphBaseUri -BaseUri 'https://graph.microsoft.com/beta'# US Government (GCC High)
Set-GraphBaseUri -BaseUri 'https://graph.microsoft.us/v1.0'- The base URI is used by
New-GraphUriwhen resolving relative paths like/users. - See National Clouds for the complete list of supported endpoints.
Attaches an Application Insights logger for dependency and exception telemetry.
| Parameter | Type | Required | Description |
|---|---|---|---|
Logger |
Object |
Yes | An AiLogger connection object returned by Connect-AiLogger. |
# Enable telemetry
$logger = Connect-AiLogger -ConnectionString 'InstrumentationKey=...'
Set-GraphAiLogger -Logger $logger# Disable telemetry
Set-GraphAiLogger -Logger $null- Requires the optional AiLogger module.
- When configured, every Graph request is logged as a dependency event with duration, result code, and success flag.
- Exceptions are logged as Application Insights exception events.
- Set to
$nullto disable telemetry without reloading the module.
Configuration
Making API Calls
Directory Objects
Files
Diagnostics
Reference