Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# Load ADAL Assemblies
$adal = "${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\Microsoft.IdentityModel.Clients.ActiveDirectory.dll"
$adalforms = "${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll"
# Set Azure AD Tenant name
$adTenant = ""
# Set well-known client ID for AzurePowerShell
$clientId = "45c1b239-339f-4b9a-b9fe-6e087e37f549"
# Set redirect URI for Azure PowerShell
$redirectUri = ""
# Set Resource URI to Azure Service Management API
$resourceAppIdURI = ""
# Set Authority to Azure AD Tenant
$authority = "$adTenant"
# Create Authentication Context tied to Azure AD Tenant
$authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authority
# Acquire token
$authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $redirectUri, "Auto")
$authHeader = $authResult.CreateAuthorizationHeader()
$authHeader | Out-File jwt.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.