Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PowerShell CmdLet as Visual Studio External Tool

I am attempting to add a PowerShell cmdlet as an external tool in Visual Studio 2010, but whenever I call the external tool I get:

{foo} cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for more details.

I have already set my system's execution policy to 'RemoteSigned' (I also tried 'Bypass'), so why is this happening? I am fully able to run that same script if I open up a command line and call it via powershell.exe path\to\script.ps1 (which is exactly what my external tool definition is calling).

like image 915
Nathan Taylor Avatar asked Oct 20 '10 23:10

Nathan Taylor


People also ask

How do I run a PowerShell script in Visual Studio?

Once it is saved as a PS1, VS Code will identify the file as a PowerShell script. From there, you can execute the PowerShell script by press F5 . You can also click the Run button on the top right of the editor. To run a select, you can press F8 or right click on the selection and click the Run Selection option.

How do I access PowerShell in Visual Studio?

Start in Visual Studio Open Visual Studio. On the menu bar, select Tools > Command Line > Developer Command Prompt or Developer PowerShell.


1 Answers

Are you running on a x64 system? If so, you have to set the execution for both x86 and x64 PowerShell. You can also pass the ExecutionPolicy directly as a parameter to Powershell (2.0) via the command line:

powershell.exe -ExecutionPolicy RemoteSigned -Command "&{ foo }"
like image 103
Keith Hill Avatar answered Oct 06 '22 07:10

Keith Hill