Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Add-AzureRmAccount
- $currentAzureContext = Get-AzureRmContext
- $tokenCache = $currentAzureContext.TokenCache
- $refreshToken = $tokenCache.ReadItems().RefreshToken
- $tenantid = $currentAzureContext.Tenant.Id
- $body = "grant_type=refresh_token&refresh_token=$($refreshToken)&resource=74658136-14ec-4630-ad9b-26e160ff0fc6"
- $tokresponse = Invoke-RestMethod "https://login.windows.net/$tenantid/oauth2/token" -Method POST -Body $body -ContentType 'application/x-www-form-urlencoded'
- $headers = @{"Authorization" = "Bearer $($tokresponse.access_token)"}
- $objid = "<UserAccountObjId>"
- $response = Invoke-RestMethod "https://main.iam.ad.ext.azure.com/api/UserDetails/$objid" -Headers $headers -Method GET
Add Comment
Please, Sign In to add comment