> For the complete documentation index, see [llms.txt](https://docs.jianny.net/work/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.jianny.net/work/azure/app-registration-auths/powershell.md).

# Powershell

<pre class="language-powershell"><code class="lang-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
            }

<strong>$oauth = Invoke-RestMethod -Method Post -Uri "https://login.microsoftonline.com/$tenantid/oauth2/v2.0/token" -Body $Body
</strong>$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
</code></pre>
