Importing modules fails for C#.NET application - file cannot be loaded because running scripts is disabled on this system.

When you're tying to import a PowerShell script into a C#.NET application you may see an error like this
File C:\Program Files\WindowsPowerShell\Modules\AzureRM\4.4.0\AzureRM.psm1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.

When you check the execution policy using Get-ExecutionPolicy it looks fine.



The issue here may be related to the application running in 32-bit mode, this has a different execution policy


Comments

Popular posts from this blog

SOLVED: Exchange Online Management PowerShell Connect-ExchangeOnline bug "A window handle must be configured. See https://aka.ms/msal-net-wam#parent-window-handles"

System error 86 has occurred. The specified network password is not correct.

The security identifier of the "NT SERVICE\WdiServiceHost" account is "S-1-5-80-3139157870-2983391045-3678747466-658725712-1809340420"