I have been using Pester for some PowerShell tests. From the command prompt all is good, but I kept getting the error ‘module cannot be loaded because scripts is disabled on this system’ when I tried to run them via the Visual Studio Test Explorer
I found the solution on StackOverflow, I had forgotten that Visual Studio is 32bit, so you need to set the 32bit execution policy. Opening the default PowerShell command prompt and and setting the policy only effect the 64Bit instance.
- Open C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe
- Run the command Set-ExecutionPolicy RemoteSigned
- My tests passed (without restarting Visual Studio)