Home » ASP » ASP.MVC » Failed to initialize the PowerShell host

Failed to initialize the PowerShell host

During the migration of Entity Framework to 6.1.0 I received an error about PowerShell host that failed to initialized.

Adding ‘EntityFramework 6.1.0’ to BusinessLogicUnitTest.
Successfully added ‘EntityFramework 6.1.0’ to BusinessLogicUnitTest.
Executing script file ‘C:\Users\Patrick\Documents\TFS\BourseVirtuelle\Code\BourseVirtuelle\packages\EntityFramework.6.1.0\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.

The problem was the system has it executions policy to restrictive. One way to fix the problem is to open a PowerShell console as administrator and to set the execution policy to unrestricted.

Set-ExecutionPolicy Unrestricted

PowerShellSetExecutionPolicy

From there, open again Visual Studio 2013 and open the Package Manager Console. This was also required before using Nuget to update Entity Framework. Opening the Package Manager Console seem to execute a Power Shell script named Profile.ps1 located in your Program Files folder.

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\b331wcwx.fbh\Modules\NuGet\Profile.ps1

If you like my article, think to buy my annual book, professionally edited by a proofreader. directly from me or on Amazon. I also wrote a TypeScript book called Holistic TypeScript

7 Responses so far.

  1. Anthony says:

    Thank you this saved my life before a deadline. I don’t know why it just stopped working though.

  2. Hi, I tried the above solution. But I am facing the following problem:

    Set-ExecutionPolicy : Access to the registry key ‘HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft
    .PowerShell’ is denied.
    At line:1 char:20
    + Set-ExecutionPolicy <<<< Unrestricted
    + CategoryInfo : NotSpecified: (:) [Set-ExecutionPolicy], UnauthorizedAccessException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.SetExecutionPolicyComma
    nd

    Can you please help or guide me so that I can troubleshoot this problem?

  3. Thank you. However, this did not work for me. I even tried running it as an Administrator, but it gives me the following error:

    Set-ExecutionPolicy : 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.”
    At line:1 char:20
    + Set-ExecutionPolicy <<<< Unrestricted
    + CategoryInfo : PermissionDenied: (:) [Set-ExecutionPolicy], SecurityException
    + FullyQualifiedErrorId : ExecutionPolicyOverride,Microsoft.PowerShell.Commands.SetExecutionPolicyCommand

    Please suggest any help, if you can.

  4. Are you running the Power Shell Console as administrator?

  5. Never mind. I installed the Service Updates for my Visual Studio 2015 & got the problem resolved. Thanks!

  6. daniel tucker says:

    Thanks! Worked like a charm.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.