Nuget gives the error "ps1 cannot be loaded because running scripts is disabled" Nuget gives the error "ps1 cannot be loaded because running scripts is disabled" powershell powershell

Nuget gives the error "ps1 cannot be loaded because running scripts is disabled"


I guess the specific package you are trying to install needs to run a Powershell script and for some reason, Powershell execution is disabled on your machine. You can search google on "how to enable Powershell" for a complete guide but generally, it goes like this:

  • Open up a Powershell command window (just search for Powershell after pressing windows start button)
  • Check out current restrictions by typing Get-ExecutionPolicy
  • Enable PowerShell by typing Set-ExecutionPolicy remotesigned

This issue does not affect the server you are planing to install your application on.


If you encounter this installing NuGet packages from Visual Studio Package Manager Console, run Visual Studio as Administrator.


enter image description here

Translation of the image text would be somewhat: This certificate has been revoked from its key store.

Certificate on my init.ps1 has expired - thus RemoteSigned will not do. For that package version to work, it would need to be set to ByPass or Unrestricted. Personally, i would not recommend doing this...

-- EDIT --I went ahead and updated the package and found they have resigned a new cert for v 1.0.2. Issue following in NuGet console for fix:

Update-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform