In VS2013, when I try to open the NuGet Package Manager Console, I suddenly get the 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 Unrestricted. Type "Get-ExecutionPolicy -List" to view your execution policy settings. For more information please see "Get-Help Set- ExecutionPolicy".
If I run 'Get-ExecutionPolicy -List' in a PowerShell prompt, I get the following:
Scope ExecutionPolicy
----- ---------------
MachinePolicy Unrestricted
UserPolicy Unrestricted
Process Unrestricted
CurrentUser RemoteSigned
LocalMachine Undefined
Not sure it this is correct or not, but on my co-workers PC, the policies are set to:
Scope ExecutionPolicy
----- ---------------
MachinePolicy Unrestricted
UserPolicy Undefined
Process Unrestricted
CurrentUser RemoteSigned
LocalMachine Undefined
Guess the problem is the 'UserPolicy' so I've tried to execute the following command:
Set-ExecutionPolicy Undefined -Scope UserPolicy
which gives me the error-message:
Set-ExecutionPolicy : Cannot set execution policy. Execution policies at the MachinePolicy or UserPolicy scopes must be set through Group Policy.
Not quite sure what to do now. Any help to fix this problem would be greatly appreciated.
To open the console in Visual Studio, go to the main menu and select Tools > NuGet Package Manager > Package Manager Console command.
Open your project or solution in Visual Studio, and then open the Package Manager Console in Visual Studio by navigating to Tools > NuGet Package Manager > Package Manager Console. By default, console commands operate against a specific package source and project as set in the control at the top of the window.
Opening the console and console controls Open the console in Visual Studio using the Tools > NuGet Package Manager > Package Manager Console command. The console is a Visual Studio window that can be arranged and positioned however you like (see Customize window layouts in Visual Studio).
This seems to happen on a workstation that is joined to a domain, and where the domain's group policy includes a specific PowerShell ExecutionPolicy setting.
For now, see the options provided here: https://powershellpanda.wordpress.com/2013/12/01/override-gpo-for-powershell-execution-policy/
Personally, I'm using the temporary fix. Temporarily clearing out the execution policy that was pushed down from my domain. (It will come back of course, but at least I can keep working for now, until a more permanent solution is found.) Here's the regedit script I use:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\PowerShell]
"ExecutionPolicy"=-
See also: https://github.com/NuGet/Home/issues/974#issuecomment-123410075
I think this only started being a problem with Visual Studio 2013 update 5, released yesterday. It affects Visual Studio 2015 (RTM), as well, by the way.
A proper nuget fix is now available (for both VS2013 and VS2015), per this post: https://github.com/NuGet/Home/issues/974#issuecomment-124774650
This has happened to me, too, with domain-set PowerShell execution policy (Unrestricted for MachinePolicy). The NuGet version is 2.8.60610.756. The Visual Studio version is Visual Studio 2013 Update 4 (12.0.31101.00; Community Edition). The symptom is that the Package Manager Console is read-only with an error message described in the question by @smolesen, and no prompt is shown.
With the workaround provided by @pbar, my installation also works fine now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With