Connect to Remote Windows Server using psexec from JenkinsPipeline
Please visit my website and subscribe to my YouTube channel for more articles
Thank you for Subscribing! If you have not, Subscribe now! DevOps4Solutions helps in providing end to end solution and…
In this blog, we will setup how we can execute scripts which is present on the remote windows server using Jenkins job
- Configure Jenkins agents on the windows system.
- Download psexec from here
- Set the environment variable in Path.
I want to run a script which is present on server “abc” from server “xyz” which needs credentials also to login to to that remote server.
Jenkins Server can be hosted either on linux/windows but the agent on which job needs to run should be be hosted on windows
The format of command as follows:
- accepteula — is required so that it wont prompt at run time to accept the connection.
- -w — provide the path where your script is present
- Full Path of file
psexec.exe \\%HOSTNAME% -u %USERNAME% -p “%PASSWORD%” -accepteula -w “E:\test” “E:\test\test.bat”
How to run from Jenkins Job
- net stop and start is required so that if there is any open connection , they will get auto deleted.
net stop workstation /y
net start workstation /y
net use “\\%HOSTNAME%\E$” %PASSWORD% /user:%USERNAME%
psexec.exe \\%HOSTNAME% -u %USERNAME% -p “%PASSWORD%” -accepteula -w “E:\test” “E:\test\test.bat”net use “\\%HOSTNAME%\E$” \delete
Congratulations, we have successfully setup how we can execute scripts which is present on the remote server.