Running PowerShell Script from the Eclipse IDE

I am trying to run a Powershell script without leaving the Eclipse IDE, so I am configuring the external tool as follows:

under the tab "main":

Location: C: \ WINDOWS \ system32 \ windowspowershell \ v1.0 \ powershell.exe

Working directory: C: \ WINDOWS \ system32 \ windowspowershell \ v1.0 \

Arguments: "& C: \ PowershellScripts \ script.ps1"

I save it and run it, but nothing happens. The console window remains open dlingaying C: \ WINDOWS \ system32 \ windowspowershell \ v1.0 \ powershell.exe in the header. I click on the red Stop button, but it seems to be happening anyway. script is not called.

What am I missing?

+3
source share
2 answers

I would probably use the -file argument, as in

-file "C:\PowershellScripts\script.ps1"

You may need to install the execution policy first, if it is not already installed on your system indefinitely.

On my machine, a 64-bit version of Windows 7 with 64-bit Eclipse and 64-bit jdk (1.6), I can make it work if I set the "arguments" field:

-executionpolicy unrestricted -file "c:\code\test.ps1"

An alternative that also worked for me was:

Set the application to run as C:\Windows\System32\cmd.exe Set the argument field to something like:

/c "powershell -executionpolicy unrestricted -file c:\code\test.ps1"

To me, this seems like an unnecessary Rouba Goldbergians, but it's worth trying to find out if your problems can work with the help of a regular shell.

I briefly got symptoms similar to what you described, but I can no longer reproduce them.

+5
source

-file:

  • : C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe
  • : C:\WINDOWS\system32\windowspowershell\v1.0\
  • : ${workspace_loc:/my-project/deploy.ps1}

script Eclipse.

"PowerShell as Administrator" :

Set-ExecutionPolicy Unrestricted

.

0

Source: https://habr.com/ru/post/1727527/


All Articles