Home

PowerShell Risky Sign In events shows 100 entries

Bas Wijdenes
Contributor

Hi All,

 

I'm using PowerShell to write the Risky Sign In events to a CSV-file. 

It only shows 100 entries though, I think I'm overseeing something easy, but can you help me out? 

 

 $loginURL = "https://login.microsoft.com"
$resource = "https://graph.microsoft.com"
$body = @{grant_type = "client_credentials"; resource = $resource; client_id = $ClientID; client_secret = $ClientSecret}
$oauth = Invoke-RestMethod -Method Post -Uri $loginURL/$tenantdomain/oauth2/token?api-version=1.0 -Body $body
Write-Output $oauth
if ($oauth.access_token -ne $null)
{
$headerParams = @{'Authorization' = "$($oauth.token_type) $($oauth.access_token)"}
$url = "https://graph.microsoft.com/beta/identityRiskEvents"
Write-Output $url
$myReport = (Invoke-WebRequest -UseBasicParsing -Headers $headerParams -Uri $url)
foreach ($event in ($myReport.Content | ConvertFrom-Json).value)
{
Write-Output $event
}
}
else
{
Write-Host "ERROR: No Access Token"
} }

 

That's the part I'm using to get all info, yet it's only 100 entries.. 

 

1 Reply

I don't have that many events in my tenant to test this, but usually it will return a "next link" element as detailed here: https://developer.microsoft.com/en-us/graph/docs/concepts/paging

Related Conversations
Extentions Synchronization
Deleted in Discussions on
3 Replies
Tabs and Dark Mode
cjc2112 in Discussions on
36 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
29 Replies