Showing results for 
Search instead for 
Did you mean: 
New Member

Use Add-PowerAppsAccount in Azure Function

I have written a script that reminds me on refreshing flows and powerapps according to a specific time rule.

Now I wanted to create an Azure function that ran every week but I do get an error that the assembly "System.Windows.Forms" could not be found.


2022-07-27T03:56:34Z [Error] EXCEPTION: The following exception occurred while retrieving member "WithAuthority": "Could not load file or assembly 'System.Windows.Forms, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified."


I call the following cmdlet:


Add-PowerAppsAccount -Username $Credentials.UserName -Password $Credentials.Password
Is there any chance to make this run?
New Member

Is there anyone who can help?

Resolver II
Resolver II

I'm assuming you're running a Powershell core version of the Azure Function (and running the latest version of Powershell core)

I'm also guessing your powershell script has the necessary commands to install the powershell modules.


One thing you could try is importing the module but use the "-UseWindowsPowerShell" argument (this generates a proxy module that uses local Windows Powershell, but I'm not sure if an Azure function running Powershell Core runtime on windows would still have the full powershell stack installed)


Another option you may consider is Azure Automation runbooks which can allow you to schedule powershell scripts execution whenever you want

Helpful resources

Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (2,530)