Forum Discussion
Anonymous
8 years agoNot applicable
PowerBi Audit Log
Hi, May I know if anyone can advise is there a way to run PowerBi analytics with the audit log? Currently I need to export the CSV file manually and import into PowerBi to run analytics pattern. ...
- 8 years agoHi there
This is what I currently use and it works really well.
http://angryanalyticsblog.azurewebsites.net/index.php/2018/02/16/power-bi-audit-log-analytics-solution/
caseycook
8 years agoHelper I
I have a SQL job that runs this PowerShell daily. I'm no PowerShell expert, I basically put together some stuff from Adam Saxton (https://guyinacube.com/about/) and MS. I'm sure it could be cleaned up. I then bring the files into Power BI...
#Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force # Option 1 - This can be used to be prompted for credentials #$UserCredential = Get-Credential #Connect-MsolService -credential $UserCredential # Option 2 - If you really want to automate the script, you will # want to hard code the credentials to log into Azure AD. $User = "[email protected]" $PWord = ConvertTo-SecureString -String "SuperSecretPassword" -AsPlainText -Force $UserCredential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $User, $PWord Connect-MsolService -credential $UserCredential # Create the session to Exchange Online $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection # Import the Exchange Online commands Import-PSSession $Session # Controls number of days to retrieve from audit log; customize as required $Number_Days = 1 # Date control variables $End_Date = (Get-Date).ToString("yyyy-MM-dd") $Start_Date = (Get-Date).AddDays(-$Number_Days).ToString("yyyy-MM-dd") $File_Date = (Get-Date).ToString('yyyy-MM-dd_hh_mm_ss') # Output folder and file; customize as required $Output_Folder = "d:\DataImports\PowerBIAuditLogs" $Csv_File = "$Output_Folder\Audit_Log-$File_Date.csv" # Check for output folder; create if required #IF (!(Test-Path $Output_Folder -PathType Container)) { #New-Item -ItemType Directory -Force -Path $Output_Folder #} # Get Audit Log data for PowerBI activities $Result = Search-UnifiedAuditLog -StartDate $Start_Date -EndDate $End_Date -RecordType PowerBI -ResultSize 5000 | Export-Csv $Csv_File # Site and document library name; customize as required; no sub-folders #$SPO_Site = "Your SharePoint Online site URL here" #$SPO_Folder = "Your Document Library name here" # Connect to SharePoint / OneDrive for Business #Connect-PNPOnline -url $SPO_Site -credential $User_Credential # Upload csv file #Add-PnPFile -Path $Csv_File -Folder $SPO_Folder Exit
Anonymous
3 years agoNot applicable
Hi Caseycook
The Script u shared is logging in using Personal Account,
Is there anyway we can connect using Azure Principal service account??