How to get session out put when we run cmd (running multiple exe files) remotely from Jenkins using powershell - powershell

How to get session output when we run cmd (running multiple exe files) remotely from Jenkins using powershell?
On Jenkins console, I can see whether the process is running or not using invoke command. But I can’t see exact output?!

Related

Execute powershell script with gitlab-runner on local windows machine

I do have following setup:
a win PC with gitlab-runner installed (working)
a powershell script running on the same PC is starting an application
a gitlab server to connect this local PC and starting the powershell script
Now when starting the powershell script directly from the local PC, the application starts and terminates after done - working as expected. When starting the same powershell script with the gitlab server (yml-file) then I can see that the application has been started (new process in taskmanager) but it is not running as well it never terminates.
When manually end the task I see that gitlab terminates again.
Question:
what could be the root cause?
is it possible to run the powershell script with gitlab-runner? I think there is a way with the command "exec". How does the command looks like when calling the powershell script?
is it possible to run the application not in the background in order to see whats going on?
others?
thanks in advance
I think there is a bug with the gitlab runner on windows.
No matter which shell you configure in the config.toml the runner
will always use cmd.exe for an exec local run.
Specify the --shell argument to override the default cmd.exe shell:
> gitlab-runner exec shell your_job --shell pwsh
If you run this locally in your project, it outputs to .builds/, so add this to your .gitignore because git will see it and think you might want to add a submodule.

Run a script to load commands into my main script

I have a powershell file that I have downloaded from ScriptCenter that allows me to control and query virtual desktops on my machine (https://gallery.technet.microsoft.com/scriptcenter/Powershell-commands-to-d0e79cc5).
Using their example, I can run that ps1 file at the start of my script to use those commands that the script creates. All fine here.
The only issue with this is that when I run my script, it asks to confirm to run it. This is something I don't want my script to do.
To work around this, I tried using the "PowerShell" command with "-ExecutionPolicy Bypass" set. This removes the prompt to approve the script, however it stops the script from being loaded into my scripts session as I can't use any of the commands it make available by running it.
How do I either run the script first, without it prompting, or execute the powershell command so that it is run in the session space of my script so that its commands are available?
Thanks

Execute jar and display text in jenkins console log

I have abc.jar file to deploy and run in remote machine.
I have transferred the file using jenkins, now what I have done is, call a a.bat batch file on remote machine using psexec in Execute Windows Batch Command.
a.bat executes the abc.jar
When the jar begins execution, the command prompt texts are stored in a file.
using java -jar abc.jar >> a.log 2>&1
Now what I want is to display the a.log contents in the jenkins console when the jar file is being executed
(the file is continuously being written and I want to show it in jenkins console as it is being written)
I have tried to do it using parallel processing by calling start twice, one for calling batch file, another using type for displaying.
But when I use start I get Process leaked file descriptor .
Is there any other way I can achieve this. Be it calling powershell or scheduled task in jenkins.
You need to look for tee equivalents in windows , there are few like GNU utilities for Win32, however if you have cygwin you can still use tee which will easy the prcoess.
Now the wuestion arises how to run my jar file on cygwin from jenkins ?
you can still use execute windows[batch] shell. and add cygwin installation path to the PATH variable and start using linux command like a BOSS.
or you can use powershell tee in built command from batch.

Is it possible to log all powershell commands run on a machine?

We have some .net applications running on a server that run powershell scripts. Is there a setting where we can log every single powershell command run on that machine, without modifying our existing applications? I already tried start-transcript . That command only captures the commands run in the current session.
I believe Microsoft calls what you're after "Over the Shoulder Transcription". It's described here, and will be available in WMF5.

Need to run sikuli script on remote PC using PsExec

I have maintained a sikuli script which runs good for a GUI application on my PC, say PC-A. Also I have PsExec installed on it. My GUI application is installed on PC-B.
What I need to do is, run the sikuli script (on PC-A) to execute for GUI app on (PC-B) using PsExec as mediator, which should pass on my commands at every single line and return the results back to PC-A from GUI application.
SikuliX Script(PC-A) ====== PsExec.exe(PC-A) ======= GUI App(PC-B)
Regards,
Bharath
To run interactively in a specific session of a remote PC you'll need to know the session id on the remote system.
You can then use psexec's -i option to run in that session. From psexec -?
-i Run the program so that it interacts with the desktop of the
specified session on the remote system. If no session is
specified the process runs in the console session.