web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Add-PowerAppsAccount f...
Power Apps
Unanswered

Add-PowerAppsAccount fails because method not found

(0) ShareShare
ReportReport
Posted on by

Hi,

I have installed the PowerApps Powershell cmdlets. I am trying to run the Add-PowerAppsAccount command without success. 

I am running version PSVersion 5.1.17763.134 on a Windows Server 2019 Datacenter edition. 

 

I get the error:

 

Add-PowerAppsAccount : Method invocation failed because Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext] does not contain a method named 'AcquireToken'.
At line:1 char:1
+ Add-PowerAppsAccount -Endpoint preview
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Add-PowerAppsAccount], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound,Add-PowerAppsAccount

 

If I try the "Add-PowerAppsAccount -username $username -password $pwd" I get a similar error 

 

New-Object : Cannot find an overload for "UserCredential" and the argument count: "2".
At C:\Program Files\WindowsPowerShell\Modules\Microsoft.PowerApps.Administration.PowerShell\2.0.1\Microsoft.PowerApps.AuthModule.psm1:64 char:23
+ ... redential = New-Object Microsoft.IdentityModel.Clients.ActiveDirector ...

 

Looks like some kind of mismatch in versions? 

Any suggestions on how I can solve this? 

Thanks in advance!

 

/Fridden

I have the same question (0)
  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @FredrikLindberg ,

    Do you import necessary PowerApps modules successfully within your PowerShell window? How do you import it?

    Which endpoint do you want your PowerShell script to run on? USGOV endpoint?

     

    I have made a test (PowerShell version 5.1.17763.316), but has a different issue with you. I would post this issue to my product team, if the issue is solved, I would reply here.

     

    Currently, I found an alternative solution to fix this issue. Before you type 'Add-PowerAppsAccount' command within your PowerShell window, please execute the following two commands firstly:

     Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force
     dir . | Unblock-File

    1.JPG

     

    The whole steps for install PowerApps PowerShell cmdlets as below:

    1. Execute the following commands firstly:

    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force
    dir . | Unblock-File

    2. Import necessary modules:

    Install-Module -Name Microsoft.PowerApps.Administration.PowerShell
    Install-Module -Name Microsoft.PowerApps.PowerShell -AllowClobber

    3. Add your PowerApps account:

    Add-PowerAppsAccount /* <-- Open a dialog to provide your credentials */

    Or

    Add-PowerAppsAccount -Username foo@bar.com -Password $pass

    Note: Please run your PowerShell as Administrator.

     

    On your side, please consider upgrade your PowerShell server to the latest version, then re-start your PC, try it again, check if the issue is solved.

    Also please consider take a try to install your PowerApps cmdlets within your PC based on the following article:

    https://docs.microsoft.com/en-us/power-platform/admin/powerapps-powershell

     

    Best regards,

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I am getting the same error on 2019 datacenter 

     

    PS C:\temp> $PSVersionTable

    Name Value
    ---- -----
    PSVersion 5.1.17763.1007
    PSEdition Desktop
    PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
    BuildVersion 10.0.17763.1007
    CLRVersion 4.0.30319.42000
    WSManStackVersion 3.0
    PSRemotingProtocolVersion 2.3
    SerializationVersion 1.1.0.1

    The unblock file does nothing and i am running as administrator too.

  • VB-31121705-0 Profile Picture
    8 on at

    I'm in the same state, running PowerShell as administrator, the workaround doesn't seem to help.

     

    Name Value
    ---- -----
    PSVersion 5.1.19041.1
    PSEdition Desktop
    PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
    BuildVersion 10.0.19041.1
    CLRVersion 4.0.30319.42000
    WSManStackVersion 3.0
    PSRemotingProtocolVersion 2.3
    SerializationVersion 1.1.0.1

     

    I'm just trying to connect to the default endpoint.

  • richardcarrigan Profile Picture
    Microsoft Employee on at

    Any resolution to this issue? I'm running PS version 5.1.19041.906 as an administrator and am encountering this issue.

  • Ee Lane Profile Picture
    37 on at

    Hi,

     

    I am facing the same issue and I have executed all the steps above. Is there a resolution for this?
    I am running PS version 5.1.19041.1023

     

  • richardcarrigan Profile Picture
    Microsoft Employee on at

    Hi @Laney ,

     

    Not necessarily a resolution, but I've found that prior to running a script using the PowerApps Admin module, I have to run 'Add-PowerAppsAccount' and authenticate first; then the script runs without error. However, if you don't run 'Add-PowerAppsAccount' first and then encounter the error, you must close the terminal window, reopen it, and then run 'Add-PowerAppsAccount and authenticate before trying to run the script again.

     

    Hope this helps!

  • richardcarrigan Profile Picture
    Microsoft Employee on at

    Hi @Laney and anyone else looking for a solution,

     

    It seems as though running the Add-PowerAppsAccount cmdlet after certain other cmdlets (Get-AzADGroup in my case), causes this error, so simply moving the Add-PowerAppsAccount to run earlier in your script solves the issue.

     

    Hope this helps!

  • PHemingway610 Profile Picture
    129 on at

    The suggested workaround steps to set execution policy and unblock file do not fix the issue.  

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 505

#2
WarrenBelz Profile Picture

WarrenBelz 502 Most Valuable Professional

#3
Haque Profile Picture

Haque 324

Last 30 days Overall leaderboard