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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
chiamaka
Frequent Visitor

Get-PowerBIActivityEvent - Unexpected error. I have Power BI Admin

$activities = Get-PowerBIActivityEvent -StartDateTime '2021-04-08T07:00:00:000' -EndDateTime '2021-04-08T10:59:59:999' | ConvertFrom-Json

 

Error message:

Get-PowerBIActivityEvent : String was not recognized as a valid DateTime.
At line:1 char:15
+ ... ctivities = Get-PowerBIActivityEvent -StartDateTime '2021-04-08T07:00 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (2021-04-08T07:00:00:000:String) [Get-PowerBIActivityEvent], FormatException
+ FullyQualifiedErrorId : StartDateTime is not a valid DateTime.,Microsoft.PowerBI.Commands.Admin.GetPowerBIActivityEvent

 

My Attempts to resolve:

1)

$activities = Get-PowerBIActivityEvent -StartDateTime '2021-04-08T07:00:00:000' -EndDateTime '2021-04-08T10:59:59:999' | ConvertFrom-Json | Out-File -FilePath C:\MyAuditLog

 

2) $activities = Get-PowerBIActivityEvent -StartDateTime '2021-04-08T07:00:00+0000' -EndDateTime '2021-04-08T10:59:59+0000' | ConvertFrom-Json | Out-File -FilePath E:\AuditLogs

 

Both attempts produce write errors and and the same 'Bad request'

 

Please can anyone help?

 

 

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

Hi @chiamaka ,

 

v-lionel-msft_1-1618281327485.png

This datetime format is not supported, please try the code below.

v-lionel-msft_0-1618281302689.png

Get-PowerBIActivityEvent (MicrosoftPowerBIMgmt.Admin) | Microsoft Docs

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

2 REPLIES 2
chiamaka
Frequent Visitor

Got it working now - I used below:


#Install-Module -Name MicrosoftPowerBIMgmt -Force
$StartDateToExtract = '2021-04-08T00:00:00'
$EndDateToExtract = '2021-04-08T23:59:59'


$activities = Get-PowerBIActivityEvent -StartDateTime $StartDateToExtract -EndDateTime $EndDateToExtract |ConvertFrom-JSON

#$activities.count

$activities | Select Id, RecordType, CreationTime, Operation, OrganisationId, UserType, Workload, UserId, ClientIP, userAgent, Activity,
ItemName, WorkspaceName, DatasetName, ReportName,
CapacityId, CapacityName, WorkspaceId, AppName, ObjectId, DatasetId, ReportId, IsSuccess,
ReportType, RequestId, ActivityId, AppReportId, DistributionMethod, ConsumptionMethod | Export-Csv -Path $activityLogOutput -NoTypeInformation

 

v-lionel-msft
Community Support
Community Support

Hi @chiamaka ,

 

v-lionel-msft_1-1618281327485.png

This datetime format is not supported, please try the code below.

v-lionel-msft_0-1618281302689.png

Get-PowerBIActivityEvent (MicrosoftPowerBIMgmt.Admin) | Microsoft Docs

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.