cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
FredrikLindberg
Level: Power Up

Add-PowerAppsAccount fails because method not found

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: (Smiley Happy [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

1 REPLY 1
Community Support Team
Community Support Team

Re: Add-PowerAppsAccount fails because method not found

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 Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

Users Online
Currently online: 52 members 3,326 guests
Please welcome our newest community members: