Score:0

How to close connection when using PSExec on multiple remote computers?

id flag

I am using PSExec to run scripts on multiple computers and after a few computers I start getting connection errors (probably because of concurrent connections limit on Windows 10).

PSExec command I am currently using:

psexec.exe @pc_list.txt -h -u psexec_username cmd /c "\\win10pc\path\script.cmd"

In the scripts I use pushd command to map the path to script/installer location, run installer if applicable and close with popd.

setlocal EnableDelayedExpansion
pushd "%~dp0"
if "!current_version!" neq "!new_version!" (msiexec /i "!installer!" /qn /norestart)
popd
endlocal

How can I close the connection after script ends on one computer and PSExec starts connecting to the next computer in the queue?

Daniel avatar
in flag
The concurrent connection limit does apply only to incoming connections. Since your connections are outgoing, this is not the cause of your issues.
jacob_w avatar
id flag
@Daniel While there is outgoing psexec connection from host to a remote computer there is also a connection from remote computer to the host (to run the script which temporarily maps remote path, verifies if and which installer to use and runs installer which is executed from the host). I would agree with you if I were to rewrite the script to copy the files and run them on remote computer (since I already have my scripts I thought closing connection might be easier).
Daniel avatar
in flag
I don't know enough about cmd scripting. But my suggestion would be to use PowerShell PSSessions to both copy file over the PSSession to the target computers and invoke whatever command or program you need to run. This will likely simplify your task.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.