Can't install nuget package because of "Failed to initialize the PowerShell host"

All of a sudden, I am getting this error when upgrading Nuget packages. None of the fixes that I have come across work. I am using Visual Studio 2013.

'Newtonsoft.Json 6.0.3' already installed.

Adding 'Newtonsoft.Json 6.0.3' to Tournaments.Notifications.

Successfully added 'Newtonsoft.Json 6.0.3' to Tournaments.Notifications.

Executing script file 'F:\My Webs\BasketballTournaments\MainBranch\packages\Newtonsoft.Json.6.0.3\tools\install.ps1'.

Failed to initialize the PowerShell host. If your PowerShell execution policy setting is set to AllSigned, open the Package Manager Console to initialize the host first.

Package Manager Console

Attempting to perform the InitializeDefaultDrives operation on the 'FileSystem' provider failed.

If I wait for the initialization to finish in the console I was able to add some packages.


Setting an execution policy to RemoteSigned or Unrestricted should work. It must be changed under an administrator mode via a PowerShell console. Be aware that changes will be applied according to the bit version of the PowerShell console, so 32bit or 64 bit. So if you want to install a package in Visual Studio (32 bit version) which requires a specific policy you should change settings of the policy via PowerShell (x86).

The command in PowerShell (as administrator) to set the policy to unrestricted (as noted by @Gabriel in the comments) is:

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

Having set the policy to unrestricted, you will want to set the policy back to its original after the install is complete.


Remember to restart Visual Studio after you've done the Set-ExecutionPolicy Unrestricted in PowerShell (x86).

If that doesn't work, try Set-ExecutionPolicy RemoteSigned in PowerShell (x86) then restart Visual Studio.


By default the PowerShell script execution is very limited for security reasons. For use within NuGet we need to open the doors.

1. Step

Open Windows PowerShell, run as Administrator

2. Step

NuGet is using the 32 bit console, so it wont be affected by changes to the 64 bit console. Run the following script to make sure you are configuring the 32 bit console.

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

3. Step

Restart Visual Studio