Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi, I want to uset powershell get-PowerBIActivityEvent to get usage logs. License is PPU.
This code works just fine with my credentials.
Is it possible to use service principal to automate this? I had no luck with it.
Error: Get-PowerBIActivityEvent : Operation returned an invalid status code 'Forbidden'
Login-PowerBIServiceAccount
$report_date = (get-date).AddDays(-1)
$start_day = $report_date.ToString("yyyy-MM-dd") + "T00:00:00"
$end_day = $report_date.ToString("yyyy-MM-dd") + "T23:59:59"
$date = $report_date.ToString("yyyyMMdd")
$filename = "pbi_log_" + $date + ".csv"
(Get-PowerBIActivityEvent -StartDateTime $start_day -EndDateTime $end_day -ResultType JsonString | ConvertFrom-Json) | select Id,RecordType,CreationTime,Operation,OrganizationId,UserType,UserKey,Workload,UserId,ClientIP,UserAgent,Activity,ItemName,WorkSpaceName,DatasetName,ReportName,WorkspaceId,ObjectId,DatasetI,ReportId,IsSuccess,ReportType,RequestId,ActivityId,DistributionMethod,ConsumptionMethod | Export-Csv "C:\pbi_log_data\$filename" -NoTypeInformation
Disconnect-PowerBIServiceAccount
Solved! Go to Solution.
Hi @aaldo_666 ,
This cmdlet requires the calling user to be a tenant administrator of the Power BI service.
Get-PowerBIActivityEvent (MicrosoftPowerBIMgmt.Admin) | Microsoft Learn
Best Regards,
Jay
Hi @aaldo_666 ,
This cmdlet requires the calling user to be a tenant administrator of the Power BI service.
Get-PowerBIActivityEvent (MicrosoftPowerBIMgmt.Admin) | Microsoft Learn
Best Regards,
Jay