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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It 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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors