Product: PowerShell Universal Version: 5.0.9
I’m creating a new API post endpoint.
The first line I’m calling New-PSDrive so I can access ConfigMgr commandlets.
I’m getting this error when it’s called.
Could not load file or assembly ‘System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=a99a5546f934e0k9’. The system cannot find the file specified.
I’m running the PowerShell 7 environment
It looks like the default PowerShell 7 environment doesn’t support windows forms.
I created a new environment using pwsh.exe.
Then it works.
Add-Type -Assembly System.Windows.Forms [System.Windows.Forms.Form]

Adam Driscoll
PowerShell Expert and Developer at Devolutions
38148a324cccc1a7c91140dccd16601653612e45.png
013dc7cb26880edbaf40f2246552237b9e6a4118.png
I created a new environment as suggested. However, now I’m getting this error
Assembly with same name is already loaded