I get an error trying to run my Pester test with PowerShell Tools for Visual Studio 2015

Problem:

When I try and run my Pester test with PowerShell Tools for Visual Studio 2015 I get this error:

Utility.tests.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.

Solution:

Execute the following command using an Administrator PowerShell.

Set-ExecutionPolicy -Force -Scope CurrentUser -ExecutionPolicy RemoteSigned

Explanation:

This is a result of the execution policy for the current user. If you issue the following command in PowerShell, you can see what the policy is at every scope.

Get-ExecutionPolicy -List

The default results will look something like this:

Scope                    ExecutionPolicy
-----
                        ---------------
MachinePolicy
   Undefined
UserPolicy
           Undefined
Process
                Undefined
CurrentUser
       Undefined
LocalMachine
    RemoteSigned

You simply need to set the CurrentUser execution policy to either RemoteSigned, Unrestricted or Bypass.  I selected RemoteSigned because it still provides some protection.

Comments (1) -

  • Make sure you do this in a x86 PowerShell Console (in C:\Windows\SysWOW64\WindowsPowerShell\v1.0). The Default Shell will open the x64. See writeabout.net/.../

Add comment

Loading