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

  • Question

  • 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
    catch {
       Write-Output "$($_.Exception.Message)"

    but it always has an error :
    Connect-PowerBIServiceAccount : Failed to get ADAL token:

    wondering if there's way to fix this problem

    Wednesday, July 17, 2019 2:20 AM

All replies

  • Hi,

    The message is pretty generic and indicates an authentican failure. There could be many reasons for that...

    just curious: what happens if you just enter 

    Connect-PowerBIServiceAccount -Credential (Get-Credential)

    and then enter the credentials, when the promtp appear? Does this work?

    (Please take a moment to "Vote as Helpful" and/or "Mark as Answer" where applicable. This helps the community, keeps the forums tidy, and recognizes useful contributions. Thanks!) Blog: Twitter: @StoyanChalakov

    Wednesday, July 17, 2019 9:28 PM
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,


    Just do it.

    Wednesday, July 31, 2019 7:43 AM