Monday, January 29, 2018

Using the REST API to Pull Info from the Microsoft Security Graph


$OAuthUri = 'https://login.microsoftonline.com/common/oauth2/token'

 

$Body = @{

    resource = 'https://graph.microsoft.com'

    client_id = 'getyourclientid'

    client_secret = 'getyourclientsecret'

    grant_type = 'client_credentials'

    redirectUri = "https://localhost:8000"

    }

 

$Response = Invoke-RestMethod -Method Post -Uri $OAuthUri -Body $Body

$Authorization = Invoke-RestMethod -Method Post -Uri $OAuthUri -Body $Body -ContentType "application/x-www-form-urlencoded" -UseBasicParsing
Write-output $Authorization

$access_token = $Authorization.access_token
Write-output $Authorization.access_token

$Headers = @{ Authorization = "Bearer $($Response.access_token)" }
$Uri = "https://graph.microsoft.com/getyourtenantname/alerts"

$Results = Invoke-RestMethod -Uri $Uri -ContentType application/json -Method Get -Headers $Headers

Write-output  $Results

 

Collecting members of the Local Administrators group using SCCM

https://blogs.technet.microsoft.com/benjamin/2018/01/27/collecting-members-of-the-local-administrators-group/