Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Export Power BI Audit Logs to .JSON files
90..1 |
foreach {
$Date = (((Get-Date).Date).AddDays(-$_))
$StartDate = (Get-Date -Date ($Date) -Format yyyy-MM-ddTHH:mm:ss)
$EndDate = (Get-Date -Date ((($Date).AddDays(1)).AddMilliseconds(-1)) -Format yyyy-MM-ddTHH:mm:ss)
Get-PowerBIActivityEvent -StartDateTime $StartDate -EndDateTime $EndDate -ResultType JsonString |
Out-File -FilePath "c:\temp\PowerBIAuditLogs\PowerBI_AudititLog_$(Get-Date -Date $Date -Format yyyyMMdd).json"
}
90..1 |
foreach {
$Date = (((Get-Date).Date).AddDays(-$_))
"$Date"
$StartDate = (Get-Date -Date ($Date) -Format yyyy-MM-ddTHH:mm:ss)
$EndDate = (Get-Date -Date ((($Date).AddDays(1)).AddMilliseconds(-1)) -Format yyyy-MM-ddTHH:mm:ss)
Get-PowerBIActivityEvent -StartDateTime $StartDate -EndDateTime $EndDate -ResultType JsonString |
Out-File -FilePath c:\temp\PowerBIAuditLogs\PowerBI_AudititLogs.json -Append
}
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.