Forum Discussion

aaldo_666's avatar
aaldo_666
Helper I
3 years ago
Solved

Run Get-PowerBIActivityEvent with Service Principal

Hi, 

I registered app in AAD and enabled Service Principal option in Power BI Admin portal.

So far I can run this cmd let:

 

$AppId = "AppId"
$TenantId = "TenantId"
$ClientSecret = "ClientSecret"

#Create secure string & credential for application id and client secret
$PbiSecurePassword = ConvertTo-SecureString $ClientSecret -Force -AsPlainText
$PbiCredential = New-Object Management.Automation.PSCredential($AppId, $PbiSecurePassword)

#Connect to the Power BI service
Connect-PowerBIServiceAccount -ServicePrincipal -TenantId $TenantId -Credential $PbiCredential

Get-PowerBIWorkspace -first 5
Get-PowerBIReport -WorkspaceId 666
Get-PowerBIDataset -WorkspaceId 666

 

AAD app permissions:

 

But Im not able to run any of MicrosoftPowerBIMgmt.Admin cmd lets. Im expecially interested in Get-PowerBIActivityEvent.

I can run Get-PowerBIActivityEvent with my credentials, but for automation I wanted to use service principal.

Any idea what permissions is service principal missing?

 

My goal it to run automatically from win scheduler:

Get-PowerBIActivityEvent -StartDateTime $start_day -EndDateTime $end_day

Thanks.