Module Import Issues in 2.3.0

Here’s another one I found after upgrading to 2.3.0 today. I have a couple of dashboards that use the MSOL and AzureAD modules to interact with Azure/O365. As of this morning in 2.2.1 my pages all worked correctly, I ran ‘Import-Module AzureAD’ and ‘Import-Module MSOnline’ at the top of each page and then called various functions throughout the page.

Now I get an error right off the bat at page load: ‘Could not load file or assembly ‘System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’. The system cannot find the file specified’ and then numerous errors when functions contained within those modules are called. Oddly enough the legacy PowerShell AD module (the one contained in the RSAT-AD-Powershell Windows feature) seems to be loading correctly.

Product: PowerShell Universal
Version: 2.3.0

Can you verify that you are running in the expected environment? If you expand the details of your dashboard, it will show which environment it’s using. I suspect it’s running in the integrated environment and might not have the Windows Forms assembly loaded.

I was using the Default environment. Manually specifying the Windows PowerShell 5.1 environment corrected the issue!

1 Like

Just a tip, if you have many automations and dashboards that require 5.1 you can go into Settings and change the default env to 5.1. Anything new will use that by default and you can set anything that needs 7.x to use that specifically

1 Like