Search code examples
powershellgitlabgitlab-ci-runnerpowershell-remoting

Powershell ISE throws RemoteException when working to GitLabRunner


I am trying to stop GitlabRunner windows service using powershell. When I execute the command in elevated powershell prompt, I see the following expected response enter image description here

Now if I run the same command in powershell ISE as Administrator It shows RemoteException error.

enter image description here

Note that the service is actually getting sopped even if the response shows error.
I get the same kind of error response with girlab-runner's other commands like register or start. Commands are working but shows error in response and only happens in ISE.


Solution

  • The implication is that your gitlab-runner.exe call sends its output to stderr, not stdout.

    Unfortunately, the ISE inappropriately renders stderr output from external programs as PowerShell errors, which is what you saw;
    a simple way to provoke the symptom is to run cmd /c 'echo to stderr >&2'

    The workaround is:

    .\gitlab-runner.exe 2>&1 | % ToString  # % is short for ForEach-Object
    

    However, you can avoid the need for workarounds by migrating away from the obsolescent ISE: