Skip to content

Instantly share code, notes, and snippets.

@SQLvariant
Last active October 3, 2019 22:08
Show Gist options
  • Save SQLvariant/ad1e4a52be3e57531e1093566b131ed1 to your computer and use it in GitHub Desktop.
Save SQLvariant/ad1e4a52be3e57531e1093566b131ed1 to your computer and use it in GitHub Desktop.
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