I get an error intermittently when attempting to connect to Microsoft Power Apps using PowerShell. Does anyone have a suggestions for what needs to be updated to make the [Add-PowerAppsAccount][1]
work reliably? You can see all the version numbers and the command process that leads to this error below.
By intermittent I mean that in a specific PowerShell session it will either work or not work, I haven't found a situation that within an active session it will work and not work, it remains consistent in the session (or at least that is what I've experienced so far.) I've found no consistency to when it works or doesn't in a new session. It'll work in a non-admin session and an admin session but then it won't work in a new non-admin or admin session. I've tried running Install-Module first and it'll sometimes work and sometimes it won't.
Name Value
---- -----
PSVersion 5.1.18362.1171
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.18362.1171
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
PS C:\> Get-Module -Name Microsoft.PowerApps.Administration.PowerShell
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 2.0.108 Microsoft.PowerApps.Administrati... {Add-AdminPowerAppsSyncUser, Add-AllowedConsentPlans, Add-...
PS C:\> Get-Module -Name Microsoft.PowerApps.PowerShell
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.0.20 Microsoft.PowerApps.PowerShell {Approve-FlowApprovalRequest, Deny-FlowApprovalRequest, Di...
PS C:\> $user ="someone@something.com"
PS C:\> $pass = ConvertTo-SecureString -String "mypassword" -AsPlainText -Force
PS C:\> Add-PowerAppsAccount -Username $user -Password $pass
New-Object : Cannot find an overload for "UserCredential" and the argument count: "2".
At C:\WindowsPowerShell\Modules\Microsoft.PowerApps.Administration.PowerShell\2.0.108\Mi
crosoft.PowerApps.AuthModule.psm1:143 char:23
+ ... redential = New-Object Microsoft.IdentityModel.Clients.ActiveDirector ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
PS C:\>