Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Add-Type -Path 'C:Program FilesMicrosoft Azure Active Directory ConnectMicrosoft.IdentityModel.Clients.ActiveDirectory.dll'
- $tenantID = "<the tenant id of you subscription>"
- $authString = "https://login.windows.net/$tenantID"
- # It must be an MFA-disabled admin.
- $username = "<the username>"
- $password = "<the password>"
- # The resource can be https://graph.windows.net/ if you are using graph api.
- # Or, https://management.azure.com/ if you are using ARM.
- $resource = "https://management.core.windows.net/"
- # This is the commond client id.
- $client_id = "1950a258-227b-4e31-a9cf-717495945fc2"
- $creds = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.UserCredential" -ArgumentList $username,$password
- $authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authString
- $authenticationResult = $authContext.AcquireToken($resource,$client_id,$creds)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement