PowerShell Script

A simple call to obtain a token using the wrapper library for MSAL.NET.

Sample Output

AccessToken                  : ey...
IsExtendedLifeTimeToken      : False
UniqueId                     : ...
ExpiresOn                    : 10/10/2021 11:05:14 AM +00:00
ExtendedExpiresOn            : 10/10/2021 11:05:14 AM +00:00
TenantId                     : ...
Account                      : Account username: ... environment login.windows.net home
                               account id: AccountId:
                           
IdToken                      : ey...
                           
Scopes                       : {email, openid, profile, https://graph.microsoft.com/Agreement.Read.All...}
CorrelationId                : ...
TokenType                    : Bearer
ClaimsPrincipal              : System.Security.Claims.ClaimsPrincipal
AuthenticationResultMetadata : Microsoft.Identity.Client.AuthenticationResultMetadata
User                         :

Code

Note that this snippet depends upon the MSAL.PS PowerShell module.

Import-Module MSAL.PS
# ClientId in this example is for Azure Active Directory PowerShell
$token = Get-MsalToken -ClientId 1b730954-1685-4b74-9bfd-dac224a7b894
$token
# $token.AccessToken

Categories:

Updated: