Microsoft Graph PowerShell supports two types of authentication: delegated and app-only access. There are a number of cmdlets that can be used to manage the different parameters required during authentication, for example, environment, application ID, and certificate.
You must invoke Connect-MgGraph before any commands that access Microsoft Graph.
This cmdlet gets the access token using the Microsoft Authentication Library
Examples
Delegated access: Using interactive authentication, where you provide the scopes that you require during your session
The subject distinguished name of a certificate.
The Certificate will be retrieved from the current user's certificate store.
Parameter properties
Type:
System.String
Default value:
None
Supports wildcards:
False
DontShow:
False
Aliases:
CertificateSubject, CertificateName
Parameter sets
AppCertificateParameterSet
Position:
2
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-CertificateThumbprint
The thumbprint of your certificate.
The Certificate will be retrieved from the current user's certificate store.
Parameter properties
Type:
System.String
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
AppCertificateParameterSet
Position:
3
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-ClientId
The client id of your application.
Parameter properties
Type:
System.String
Default value:
None
Supports wildcards:
False
DontShow:
False
Aliases:
AppId, ApplicationId
Parameter sets
AppCertificateParameterSet
Position:
1
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
UserParameterSet
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
IdentityParameterSet
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-ClientSecretCredential
The PSCredential object provides the application ID and client secret for service principal credentials.
For more information about the PSCredential object, type Get-Help Get-Credential.
Parameter properties
Type:
System.Management.Automation.PSCredential
Default value:
None
Supports wildcards:
False
DontShow:
False
Aliases:
SecretCredential, Credential
Parameter sets
AppSecretCredentialParameterSet
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-ClientTimeout
Sets the HTTP client timeout in seconds.
Parameter properties
Type:
System.Double
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
AppCertificateParameterSet
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
AppSecretCredentialParameterSet
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
AccessTokenParameterSet
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
UserParameterSet
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
IdentityParameterSet
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
EnvironmentVariableParameterSet
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-ContextScope
Determines the scope of authentication context.
This accepts Process for the current process, or CurrentUser for all sessions started by user.
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters.