Can’t Install NuGet Package Because of “Failed to initialize the PowerShell host”

I was attempting to install the Newtonsoft.Json v. 6.0.4 NuGet Package in a project and received an error message beginning with the text, “Failed to initialize the PowerShell host…”.  Interesting.  I know the PowerShell execution policy can be restrictive by default so I opened Visual Studio 2013’s Package Manager Console and entered the command:


It came back as RemoteSigned.  RemoteSigned **should** be fine for this package and for any package in the public NuGet feed.  I thought perhaps something was overlooked in the signing of the published package so I changed the execution policy in my Package Manager Console (note: Visual Studio has to be run as Administrator to do this).

Set-ExecutionPolicy Unrestricted

An Unrestricted policy doesn’t care if the package is signed or not; it’s a run-at-your-own-risk setting.  But still, I received the same error!  I ran Get-ExecutionPolicy and noticed it was still set to RemoteSigned.  So it was time to do some Goggling and I ran across a great StackOverflow answer and accompanying comment for this same problem.  The poster to the answer stated,

Be aware that changes will be applied according to the bit version of the PowerShell console, so 32bit or 64 bit.

I use a 64 bit environment so this had to be the problem!  A commenter to that StackOverflow answer posted how to actually do this in the Package Manager Console:

start-job { Set-ExecutionPolicy Unrestricted } -RunAs32 | wait-job | Receive-Job

Once I ran that, Get-ExecutionPolicy returned Unrestricted.  I made another attempt to install the NuGet package and it worked!

Leave a Reply

Your email address will not be published.