This is a quick solution guide to the error- Failed to initialize the PowerShell host while installing packages.
Yes, if you’re a Visual Studio 2019 user then you might come across this error while creating a new project or adding a package using the Nuget package manager. The error popup will look something like below-

When Failed to initialize the PowerShell host while installing packages Error Appears
There are a couple of places when such error can come-
- While creating a new project in visual studio
- While adding a new package using Nuget package
While I received this error while creating a new project, many users received it while installing the NEST Nuget package. People have received the error like-
Fix to Failed to initialize the PowerShell host while installing packages
I tried different solution looking at the internet starting with the below-
Solution-1 [Didn’t work]- updating the execution policy by executing the following in a PowerShell opened as Administrator
start-job { Set-ExecutionPolicy Unrestricted } -RunAs32 | wait-job | Receive-Job
But this didn’t work and received the below error-
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
RemoteSigned. Type “Get-ExecutionPolicy -List” to view your execution policy settings. For more information please see
“Get-Help Set-ExecutionPolicy”.
+ CategoryInfo : PermissionDenied: (:) [Set-ExecutionPolicy], SecurityException
+ FullyQualifiedErrorId : ExecutionPolicyOverride,Microsoft.PowerShell.Commands.SetExecutionPolicyCommand
Solution-2 [Didn’t Work]
Further I tried to set it to RemoteSigned instead of Unrestricted by executing the below code-
start-job { Set-ExecutionPolicy RemoteSigned } -RunAs32 | wait-job | Receive-Jobb
Although this code didn’t give any error and executed successfully but the issue didn’t get resolve. I restarted Visual Studio but the issue was there itself.
Solution-3 [Worked]
When the above 2 solutions didn’t work for me, started looking for alternate and finally found this one which worked. Here I reinstalled Nuget Package manager for Visual Studio using the below steps and it worked.
- In Tools -> Extensions and Updates, uninstall NuGet Package Manager for Visual Studio
- Restart Visual Studio
- In Tools -> Extensions and Updates, install NuGet Package Manager for Visual Studio
- Restart Visual Studio
That’s all!
After this I was able to install JSON.NET package as well other then creating the projects in visual studio.
Final Words
This was all about how to fix Failed to initialize the PowerShell host while installing packages in Visual Studio. The solution is pretty simple and if you’re facing this issue too, please follow the same. For more articles, keep visiting GoTechHero.