Powershell: Could not load file or assembly 'System.Windows.Forms`

Created on 11 Mar 2018  路  5Comments  路  Source: PowerShell/PowerShell

Hi guys
I am trying to install and use AzureRM on my mac. I have successfully installed all Azure RM component. However, the Import-Module is failing.

Steps to reproduce

PS /Users/reza> Import-Module AzureRM.Profile
Import-Module : 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.
At line:1 char:1
+ Import-Module AzureRM.Profile
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.ImportModuleCommand

Environment data

> $PSVersionTable

PS /Users/reza> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.0.1
PSEdition                      Core
GitCommitId                    v6.0.1
OS                             Darwin 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Issue-Question Resolution-Answered

Most helpful comment

@rezamt,

It's known that AzureRm modules only works in Windows. You need to use the AzureRm.Netcore modules which will provide a smaller subset of modules enough to work with Azure.

The current version of AzureRm.Netcore is v0.10.0.:

Name                      Version
----                      -------
AzureRM.Compute.Netcore   0.10.0
AzureRM.KeyVault.Netcore  0.10.0
AzureRM.Netcore           0.10.0
AzureRM.Network.Netcore   0.10.0
AzureRM.Profile.Netcore   0.10.0
AzureRM.Resources.Netcore 0.10.0
AzureRM.Storage.Netcore   0.10.0
AzureRM.Tags.Netcore      0.10.0
AzureRM.Websites.Netcore  0.10.0

Also, remember that in PowerShell Core there's no Windows Form. So, follow the text message instructions to login to Azure from your device.

Feel free to check my blog post on AzureRm.Netcore: http://www.maxtblog.com/2017/12/working-with-azure-resource-manager-cross-platform-with-powershell-core/

Hope this will work!
:)

All 5 comments

@rezamt,

It's known that AzureRm modules only works in Windows. You need to use the AzureRm.Netcore modules which will provide a smaller subset of modules enough to work with Azure.

The current version of AzureRm.Netcore is v0.10.0.:

Name                      Version
----                      -------
AzureRM.Compute.Netcore   0.10.0
AzureRM.KeyVault.Netcore  0.10.0
AzureRM.Netcore           0.10.0
AzureRM.Network.Netcore   0.10.0
AzureRM.Profile.Netcore   0.10.0
AzureRM.Resources.Netcore 0.10.0
AzureRM.Storage.Netcore   0.10.0
AzureRM.Tags.Netcore      0.10.0
AzureRM.Websites.Netcore  0.10.0

Also, remember that in PowerShell Core there's no Windows Form. So, follow the text message instructions to login to Azure from your device.

Feel free to check my blog post on AzureRm.Netcore: http://www.maxtblog.com/2017/12/working-with-azure-resource-manager-cross-platform-with-powershell-core/

Hope this will work!
:)

Thanks tried and its working, but it wasn't mentioned in any documentation :(

And your blog is awesome. :)

Note for anyone finding their way here via Google, AzureRm and Netcore is now deprecated.
https://docs.microsoft.com/en-us/powershell/azure/new-azureps-module-az

Is there any solution for this error btw? I firghting with AzureAD module, it also depends on System.Windows.Forms assembly and I cannot use this module on Linux.

AzureAD is not Core-compatible; you'll need to use their newer Az module.

Was this page helpful?
0 / 5 - 0 ratings