Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
aaldo_666
Frequent Visitor

Automate getting PBI logs

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

1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

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

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

1 REPLY 1
v-jayw-msft
Community Support
Community Support

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

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Top Solution Authors