Skip to content

Instantly share code, notes, and snippets.

Embed
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 'your.email@somewhere.com'
90..1 |
foreach {
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session
$Start=((Get-Date).Date).AddDays(-$_);
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
You can’t perform that action at this time.