Exports the PowerBI events from the O365 Audit Log into separate .CSV files for each of the last 90 days.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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