Guest User

Untitled

a guest
Mar 20th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. Add-AzureRmAccount
  2. $currentAzureContext = Get-AzureRmContext
  3. $tokenCache = $currentAzureContext.TokenCache
  4. $refreshToken = $tokenCache.ReadItems().RefreshToken
  5. $tenantid = $currentAzureContext.Tenant.Id
  6.  
  7. $body = "grant_type=refresh_token&refresh_token=$($refreshToken)&resource=74658136-14ec-4630-ad9b-26e160ff0fc6"
  8. $tokresponse = Invoke-RestMethod "https://login.windows.net/$tenantid/oauth2/token" -Method POST -Body $body -ContentType 'application/x-www-form-urlencoded'
  9.  
  10. $headers = @{"Authorization" = "Bearer $($tokresponse.access_token)"}
  11. $objid = "<UserAccountObjId>"
  12. $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