Advertisement
Guest User

Untitled

a guest
May 3rd, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. Add-Type -Path 'C:Program FilesMicrosoft Azure Active Directory ConnectMicrosoft.IdentityModel.Clients.ActiveDirectory.dll'
  2.  
  3. $tenantID = "<the tenant id of you subscription>"
  4. $authString = "https://login.windows.net/$tenantID"
  5.  
  6. # It must be an MFA-disabled admin.
  7. $username = "<the username>"
  8. $password = "<the password>"
  9.  
  10. # The resource can be https://graph.windows.net/ if you are using graph api.
  11. # Or, https://management.azure.com/ if you are using ARM.
  12. $resource = "https://management.core.windows.net/"
  13.  
  14. # This is the commond client id.
  15. $client_id = "1950a258-227b-4e31-a9cf-717495945fc2"
  16.  
  17. $creds = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.UserCredential" -ArgumentList $username,$password
  18. $authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authString
  19.  
  20. $authenticationResult = $authContext.AcquireToken($resource,$client_id,$creds)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement