Powershell

$tenantid = ""
$secret = ""
$clientid = ""
$scope = ""
$username=""
$password=""
$grant_type=""

$Body  = @{
            grant_type=$grant_type;
            client_id=$clientid;
            scope=$scope;
            client_secret=$secret
            username=$username
            password=$password
            }

$oauth = Invoke-RestMethod -Method Post -Uri "https://login.microsoftonline.com/$tenantid/oauth2/v2.0/token" -Body $Body
$Header= @{'Authorization'="$($oauth.token_type) $($oauth.access_token)"}

$uri = "https://graph.microsoft.com/v1.0/"
$response =Invoke-RestMethod -Headers $Header -Uri $uri -Method GET -ContentType 'application/json' -Verbose

Last updated