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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

ADAL token problem when connecting to PowerBI Service via API from powershell

hi, 

 

I'm trying to connect to powerBI by using API from powershell.

 

this is the code that I'm using:

$common = $PSScriptRoot + "\common.ps1"
. $common

##set parent directory for this file
#set project setting file
$parentfDir = Split-Path $PSScriptRoot -Parent 
$confDir = getFilePath $parentfDir "\json\automation_tools_seting.json"

#get project settings and package parameter
$conf = loadJsonFile $confDir

$user = $conf.PBI_user
$pass = $conf.PBI_pass | ConvertTo-SecureString -asPlainText -Force

$credential = New-Object System.Management.Automation.PSCredential ($user, $pass)
try {
    Connect-PowerBIServiceAccount -Credential $credential

    Disconnect-PowerBIServiceAccount
}
catch {
   Write-Output "$($_.Exception.Message)"
    
}

but it always has an error :

Connect-PowerBIServiceAccount : Failed to get ADAL token:

 

wondering if there's any mistake inside my code

0 REPLIES 0

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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