Created
December 30, 2020 10:55
-
-
Save gsscoder/d07b070b7acd2800c1d51a8d064e92b2 to your computer and use it in GitHub Desktop.
PowerShell code to get the bearer token using an app registration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $tenantId = 'your_tenant_id' | |
| $clientId = 'your_client_id' | |
| $clientSecret = 'your_client_secret' | |
| $tokenResponse = (Invoke-WebRequest -Uri "https://login.microsoftonline.com/$tenantId/oauth2/token" ` | |
| -Method Post -UseBasicParsing ` | |
| -Body "grant_type=client_credentials&client_id=$clientId&client_secret=$clientSecret").Content | |
| "$(($tokenResponse | ConvertFrom-Json).access_token)`n" | Write-Host |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment