[powershell] 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.

The answer is


VS2015: Updated the NuGet and worked.


If none of the above helps, see if you can update Visual Studio.

I Had the same issue with Visual Studio 2017 Community when I tried to install Newtonsoft.Json. The ExecutionPolicy change didn't help (I tried using both PowerShell and Registry Editor). I also tried to uninstall and install NuGet.

After running VS2017 setup file, it asked for update of Visual Studio. All the problems disappeared after the update.


This issue is not always related to the PowerShell Execution Policy. My machine is configured as "Unrestricted" for both PowerShell x64 and x86, but I still get this error message from times to times in Visual Studio 2013.

When I try to open the Package Manager Console:

Windows PowerShell updated your execution policy successfully, but the setting is overridden by a policy defined at a more specific scope. Due to the override, your shell will retain its current effective execution policy of Unrestricted. Type "Get-ExecutionPolicy -List" to view your execution policy settings. For more information please see "Get-Help Set-ExecutionPolicy".

This is not a valid error message.

Rebooting Visual Studio does not always resolve the problem.

Running the process as an admin never resolves the problem.

Like Declan, the latest update of the Package Manager plugin fixed the issue: 2.8.60723.765


I updated the Nuget package manager and that fixed it for me.


Download and Install Administrative Templates for Windows PowerShell

Next:  Powershell x86 from As Administrator

Run:   Get-ExecutionPolicy -List  , and see if you have RemoteSigned etc..

1. 5 different scopes  Set-ExecutionPolicy "RemoteSigned" -Scope Process -Confirm:$false

2. Machine and User Policy you have to set through the Group Policy Administration Template in 2 areas.

UPDATE - EDIT:

Set ALL of them to  "Undefined" and ONLY the LocalMachine to "Restricted" 

This is what fixed might after I had given my powershell more permissions not knowing that it would mess up visual studio 2013 and 2015


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.


My problem solved, because in this time .Net Core not supported EF 6.2.0.

change project from Core and EF installed successfully.



I had this issue with my Visual Studio 2015. I uninstalled and re-installed NuGet Package Manager again. It worked for me.


By default my Windows 10 64-bit only had Powershell version 1.0 enabled. I changed the control panel/Programs/Programs and features/Turn Windows features On Off.

Make sure the Windows Powershell 2.0 engine is enabled.

Restart VS2015 in non-administrator mode and with all packages installed correctly.


After trying various suggested fixes, it was finally solved by updating the NuGet Package Manager extension in Visual Studio.

This is done under Tools -> Extensions And Updates, then in the Extensions and Updates dialog Updated -> Visual Studio Gallery. A restart of Visual Studio may be required.


I had a similar problem. I have fixed it by turning "Windows PowerShell 2.0" feature on in "Turn Windows features on or off". Note that this feature is turned on by default, I manually turned it off few days ago.

I'm working on Windows 10 Pro 64bit and same problem was with Visual Studio 2015 and 2017 (32bit and 64bit app)


Running the Visual Studio as Administrator worked for me.


after trying all the suggested solution nothing worked on VS 2015 update 2

deleting the package folder from the solution folder and restoring it from visual studio worked for me


I run this command on powershell (run as admin) and it solve my issue.

reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\PowerShell /v ExecutionPolicy /f

If the above answers dint work for you -

  1. Open Run - windows + R
  2. Open registry editor - type regedit.exe
  3. Open - HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\PowerShell
  4. In the right pane - Modify "ExecutionPolicy" and keep its "Value Data" as blank.
  5. Restart your visual studio, Now your Powershell can initialize properly.

I had the same problem with vs2013 and changing execution policy did not fix it. The only working solution I found was uninstalling Nuget from VS and installing it again. Steps are here: https://stackoverflow.com/a/32619961/3853238


Set the execution policy to Bypass instead of Unrestricted or RemoteSigned; this tutorial gives fuller instructions. Also, if you are having trouble using PowerShell to change the policy then the author shows you how to change it in Regedit.


Close all the visual studio instances and try again. It worked for me :)


What worked for me is:

  1. Set Execution policy to Unrestricted.
  2. Find-Module ISEModuleBrowserAddon | Install-Module
  3. Import-Module ISEModuleBrowserAddon
  4. Find-Module ISEScriptAnalyzerAddOn | Install-Module
  5. Import-Module ISEScriptAnalyzerAddOn
  6. Import-Module ScriptBrowser
  7. In ISE, you need Enable-ScriptBrowser

And you have Module, Script, and Analyser in your ISE.

Run in Win 10 Pro, x64 Console Host 5.0.10586.122

Good Luck!


Apparently there is a Powershell bug in Windows 10 version 1511.

None of the fixes listed here worked for me. (or only worked temporarily)

I fixed it (both in VS2013 and VS2015) by installing version 1607. It can be downloaded here: Windows 10 Anniversary Update.

Nuget issue: https://github.com/NuGet/Home/issues/3352


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


All I needed to do was restart Visual Studio, open the NuGet Package Manager Console, and then using the Manage NuGet Packages dialog worked.


If you use VS 2013 Update 5, you should manually install an update 2.8.7 for NuGet Packet Manager.

The bug report has more details.


For me setting the execution policy to Unrestricted did not work. I had to repair the vs2013 installation by going into Control Panel. Repairing the installation worked for me.


What did the trick for me was to re-install NuGet Package Manager by using the link below:

VS 2013: https://github.com/NuGet/Home/releases/download/2.8.7/NuGet.Tools.vsix

VS 2015: https://github.com/NuGet/Home/releases/download/3.1.1/NuGet.Tools.vsix


Had the same problem and this solved it for me (Powershell as admin):

Set-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\PowerShell -Name ExecutionPolicy -Value ByPass 

No answers have worked for me.

All policies were correct but I have the error when installing a package

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.

The solution : I have uninstalled the nuget package manager plugin and reinstalled it.


You need to open PM console( Tools > Nuget Package Manager > Package Manager Console), it will prompt you if you want to run nuget manager as untrusted , type 'A' and click enter that will resolve the issue.


This started happening with 6.0.4 recently for me, I don't think this is a very good solution but here is what helped me. Close Visual Studio

  1. Open a Windows PowerShell prompt as Administrator (very important) and run the following command:Set-ExecutionPolicy Bypass
  2. Open Visual Studio, open your solution and use Nuget to install JSON.Net (or whatever package included it as a dependency).
  3. Once everything is working, I recommend setting the powershell execution policy back to restricted with the following command: Set-ExecutionPolicy Restricted

I had the same problem after upgrading to Windows 10.

This worked for me

  1. Close Visual Studio
  2. Run Powershell as admin
  3. Run Set-ExecutionPolicy Unrestricted
  4. Run Visual studio as admin
  5. Clean the project and add the nuget package

If it still doesn't work try editing devenv.exe.config

Visual Studio 2013: C:\Users\<UserName>\AppData\Local\Microsoft\VisualStudio\12.0

Visual Studio 2015: C:\Users\<UserName>\AppData\Local\Microsoft\VisualStudio\14.0

Add the following

    <dependentAssembly>
        <assemblyIdentity name="System.Management.Automation" publicKeyToken="31bf3856ad364e35" />
        <publisherPolicy apply="no" />
    </dependentAssembly>
    <dependentAssembly>
      <assemblyIdentity name="Microsoft.PowerShell.Commands.Utility" publicKeyToken="31bf3856ad364e35" />
      <publisherPolicy apply="no" />
    </dependentAssembly>
    <dependentAssembly>
      <assemblyIdentity name="Microsoft.PowerShell.ConsoleHost" publicKeyToken="31bf3856ad364e35" />
      <publisherPolicy apply="no" />
    </dependentAssembly>
    <dependentAssembly>
      <assemblyIdentity name="Microsoft.PowerShell.Commands.Management" publicKeyToken="31bf3856ad364e35" />
      <publisherPolicy apply="no" />
    </dependentAssembly>
    <dependentAssembly>
      <assemblyIdentity name="Microsoft.PowerShell.Security" publicKeyToken="31bf3856ad364e35" />
      <publisherPolicy apply="no" />
    </dependentAssembly>
    <dependentAssembly>
      <assemblyIdentity name="Microsoft.PowerShell.Commands.Diagnostics" publicKeyToken="31bf3856ad364e35" />
      <publisherPolicy apply="no" />
    </dependentAssembly>

I have the same issue with the Manage NuGet Packages dialog, I use a work-around that may help others - running from package manager console:

If I use the command line powershell commandlet install-package, all is fine.

I am adverse to changing a security setting "just to make it work".


There are an awful lot of stabs in the dark here, so I'll add my own.

In my case, I also got a message that there was a missing lock file, and a recommendation to run dnu restore in the package manager console. I did so, restarted VS, and everything is now working.


Examples related to powershell

Why powershell does not run Angular commands? How do I install the Nuget provider for PowerShell on a unconnected machine so I can install a nuget package from the PS command line? How to print environment variables to the console in PowerShell? Check if a string is not NULL or EMPTY The term 'ng' is not recognized as the name of a cmdlet VSCode Change Default Terminal 'Connect-MsolService' is not recognized as the name of a cmdlet Powershell Invoke-WebRequest Fails with SSL/TLS Secure Channel Install-Module : The term 'Install-Module' is not recognized as the name of a cmdlet Change directory in PowerShell

Examples related to visual-studio-2013

Microsoft Advertising SDK doesn't deliverer ads Visual Studio 2013 error MS8020 Build tools v140 cannot be found Visual Studio 2013 Install Fails: Program Compatibility Mode is on (Windows 10) 'cannot find or open the pdb file' Visual Studio C++ 2013 Force uninstall of Visual Studio How to enable C# 6.0 feature in Visual Studio 2013? Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE] even if app appears to not be installed Process with an ID #### is not running in visual studio professional 2013 update 3 Error C1083: Cannot open include file: 'stdafx.h' The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)"

Examples related to nuget

How do I install the Nuget provider for PowerShell on a unconnected machine so I can install a nuget package from the PS command line? How to use Bootstrap 4 in ASP.NET Core Assets file project.assets.json not found. Run a NuGet package restore .net Core 2.0 - Package was restored using .NetFramework 4.6.1 instead of target framework .netCore 2.0. The package may not be fully compatible Nuget connection attempt failed "Unable to load the service index for source" Getting "project" nuget configuration is invalid error Build error, This project references NuGet Unable to Install Any Package in Visual Studio 2015 NuGet Packages are missing How can I clear the NuGet package cache using the command line?

Examples related to powershell-2.0

Extract the filename from a path Out-File -append in Powershell does not produce a new line and breaks string into characters Using PowerShell to remove lines from a text file if it contains a string PowerShell The term is not recognized as cmdlet function script file or operable program Can't install nuget package because of "Failed to initialize the PowerShell host" Powershell script to see currently logged in users (domain and machine) + status (active, idle, away) How to export data to CSV in PowerShell? powershell is missing the terminator: " PowerShell script to check the status of a URL How to upgrade PowerShell version from 2.0 to 3.0

Examples related to nuget-package

Install a Nuget package in Visual Studio Code How can I clear the NuGet package cache using the command line? Can't install nuget package because of "Failed to initialize the PowerShell host" How to connect to MySQL Database? 'nuget' is not recognized but other nuget commands working How can I install an older version of a package via NuGet? Is it possible to change the location of packages for NuGet?