Running psexec from jenkins not showing logs - windows

I have Jenkins with 'Execute Windows Batch Command' that runs PsExec on a second computer configured with Execute Windows Batch Command
and set to cmd /c "FooPsExec.bat"
When I run the Jenkins I do not see the execution of PsExec logs and all I see is:
"c:\pstools\PsExec.exe" XXXXXXXXX
PsExec v1.98 - Execute processes remotely
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com
And that's it, I can see that the process is running on the remote computer however I want to see the logs on Jenkins
If I open cmd on the Jenkins and run the FooPsExec.bat (not via Jenkins) it is working and logs are shown appropriately
How can I make the logs to be visiable

You can use PaExec http://www.poweradmin.com/paexec/, which is an advanced version of PsExec

Related

How to run a bat script on multiple windows servers at once?

I am trying to run a .bat script that uninstall 32/64 bit agents and re-install 64-bit agents on almost 100 window servers.
Can you please guide me how this can be done?
I already tried running for one server to test
psexec \\<windows server> -u <username> -p <password> <command>
But fails with error
COULD NOT START PSEXESVC service on <windows server>
Do we need such service on all machines? Please suggest any other way?
PSEXEC is not a standard windows feature /service.
If you wish to use PS Exec you will need to install it on all of the relevant systems first.
Otherwise, your options are:
CMD:
A) Does the "Agent" Installer you are using allow you to install / uninstall to a given server in it's command line syntax?
If so utilize that.
B) Put the Installer in central location (the Active Directory Netlogon Folder is great for this) along with a CMD script to run the uninstall and install processes.
Then Use SCHTasks to connect to each server and create a Scheduled task that runs using an administrative Username and password for that server, and set it to run with the highest privileges, set the action to be the path to the CMD script in netlogon that you have previously tested and nwo is working, set the task to run 1 minute in the future, or on demand (If on demand you then run schtasks again to execute the task).
Powershell:
Work on getting a working CMD Script to run and use Invoke Command to run that command script on the remote systems. As in Option B from CMD options you can keep the CMD script and Agent installer in the netlogon folder.

Run a cmd command in batch script as an Administrator without UAC prompt

I have a batch file with various commands. I am transferring the batch file to a remote PC and running the file. Now I need to run a few of the commands in the batch file as an administrator but I cannot go to the remote PC to enter any password or click on any prompt.
My batch file includes the following commands:
1. winrm quickconfig -force
2. winrm set winrm/config/service/auth #{Basic="true"}
3. winrm set winrm/config/service #{AllowUnencrypted="true"}
Now the commands 2 and 3 needs to be run as an administrator. I have the admin password. Is there any command arguments like
"command" /runas /user:admin /pass:password /noprompt
Using only /runas still gives you a prompt and there is no option in runas /? that can disable it. I need a solution where I don't have to press Yes on the UAC prompt since the file will run on a remote system.
Edit: Would like to give more context. So the task is to automate the process of running configuration script on remote machine once windows is installed on it. There would be approximately 100 machines and going on each system and enabling the winrm service is not feasible. And in order to run the script remotely on the target machine, I need to enable and then make changes to the winrm service (needs admin privileges). I cannot make changes to the network. I am able to enable winrm service but making changes to winrm service requires running those commands as admin. And I cannot click on any prompt since I cannot go to the remote machine. So any advice in this regards would be helpful. I'm not trying to bypass any process. I have the admin credentials. Just trying to find the correct commands and arguments to help me achieve this.

PsExec could not start app: The system cannot find the file specified

This question has been asked many times elsewhere.. but they are mostly about running things on a remote computer etc. Mine is much more straight forward.
I got an app (let's call it app.exe), which runs by a service. When it runs by the service, it is ran by the SYSTEM user.
However the app is acting weird, further when I run the same app by simply clicking on the .exe file, it runs it but with the logged in user account:
So I simply want to run the same app as system, that's where I found the psExec command. If I run the psExec command like so
c:\path\BOT>psExec "*** Bot.exe"
PsExec v2.2 - Execute processes remotely
Copyright (C) 2001-2016 Mark Russinovich
Sysinternals - www.sysinternals.com
it works just fine, but once i put the -s switch (ie to run as system).. it blows up:
c:\path\BOT>psExec -i -s "*** Bot.exe"
PsExec v2.2 - Execute processes remotely
Copyright (C) 2001-2016 Mark Russinovich
Sysinternals - www.sysinternals.com
PsExec could not start *** Bot.exe on SAMERDERNAI5012:
The system cannot find the file specified.
this answer states that if the cmd window is ran as non-admin, then it should work. I tried that but nothing happend.
I expect the bot.exe file is not in the list of directories in the PATH environment variable for the SYSTEM user.
To system the system version of PATH open system control panel (Windows Key+Break), go to Advanced System Settings, and then Environment Variables.

Team City Version 9.0 hangs when running a PSEXEC command

I am using Team City version 9 on a Windows Server 2012 machine. I have a build step in my Team City project that uses psexec to runs a command line script on a remote computer. The remote computer is Windows Server 2008 Standard 32-bit with SP2. One line in the team city script is:
\\Aenyfs01\APPS1\Winstall75\PSTools\psexec.exe \\aewebsvctst4 \\aewebsvctst4\deployScripts\stopwebsite.cmd SCRIBE2QA1TEST -accepteula
When Team City gets to this line it starts running PSEXEC and then hangs. I found another thread that said to use the -accepteula to suppress the license screen.
This line is using psexec to run a command script from the remote machine called aewebsvctst4. I have psexec installed on that remote machine and ran psexec from the remote machine's windows explorer. I got the license screen and clicked OK.
When I run this command from the team city build server machine it works fine. But running in Team City just causes it to hang.
Here is the output from the build log in Team City:
[Step 2/3] C:\TeamCity_Working\Distribution\SCRIBE\Trunk>\\Aenyfs01\APPS1\Winstall75\PSTools\psexec.exe \\aewebsvctst4 \\aewebsvctst4\deployScripts\stopwebsite.cmd SCRIBE2QA1TEST -accepteula
[18:05:55][Step 2/3]
[18:05:55][Step 2/3] PsExec v1.98 - Execute processes remotely
[18:05:55][Step 2/3] Copyright (C) 2001-2010 Mark Russinovich
[18:05:55][Step 2/3] Sysinternals - www.sysinternals.com
[18:05:55][Step 2/3]
[18:05:55][Step 2/3]
Does anyone have any ideas?
Thanks,
Glenn

"plink.exe" hangs on Windows Server 2008 R2, creates process "conhost.exe"

I am new to the whole Windows world. I have downloaded plink.exe from Putty's website. I am executing a plink command from the Windows Server 2008 R2(64 bit) which would execute a shell script in a Linux box.
The plink command is executed from a .dtsx package which is running as a daemon job on the Windows Server. I have accepted the host key into the registry for the Linux box using Putty and I can see it in the registry.
The command executes when I RDP into the server but does not when I am not logged in. It hangs and creates a "conhost.exe" process which stays there. I can see the "plink.exe" and "conhost.exe" in the task manager on the server.
Here is the kind of command I am running.
plink.exe user#SERVERNAME -pw password ./script_name.sh param_1 param_2 param_3
Has anybody faced/or is facing any problem like this?

Resources