Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Exports the PowerBI events from the O365 Audit Log into separate .CSV files for each of the last 90 days.
$UserCredential = Get-Credential ''
90..1 |
foreach {
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session
Search-UnifiedAuditLog -StartDate $Start -EndDate $Start.AddDays(1) -RecordType PowerBI -ResultSize 5000 |
Export-Csv -Path "c:\temp\PowerBIAuditLogs\PowerBIAudit_Log_$(Get-Date -Date $Start.AddDays(1) -Format yyyyMMdd).csv" -NoTypeInformation
Remove-PSSession $Session
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment