Windows – PsExec Slow to connect when Windows Firewall Enabled

firewallremotewindowswindows-firewall

situation:

running PsExec takes 20 seconds with windows firewall and 1 second with it disabled.

Exceptions added to firewall:

opened ports 135 and 445 (both tcp) as per http://jamesrayanderson.blogspot.co.uk/2010/04/psexec-and-ports.html

"allow app through firewall" choose "Remote Service Management"

ensure network is set to private

without these two it wont connect at all. Target machine running windows 10

during the 20 second wait it sits saying "Starting PsEXESVC on "

ok so a little wiresharking shows us that we need to also open another port which is being requested.

first time I ran this it was 49669 second time it was 49670

no idea why nor what range it will accept, any ideas?

is there a definitive list of what ports PSEXEC needs to have opened?
failure to move to a different port introducing delay with windows firewall enabled on windows 10 (all inbound "Remote..." firewall rules are enabled )

Best Answer

Apparently this is an issue with the Group Policy client when enabling "Remote Service Management".

The fix is to run the following command:

netsh advfirewall firewall set rule name="Remote Service Management (RPC)" profile=domain new enable=yes

I did this in bulk, remotely, using PsExec (which ran slowly) as follows, given the affected workstations, one computer name per line, in workstations.txt:

for /f %i in (workstations.txt) do @start /B psexec \\%i netsh advfirewall firewall set rule name="Remote Service Management (RPC)" profile=domain new enable=yes

Doing psexec @workstations.txt (instead of using a for loop) would still run the commands in serial, slowly, with the 20-ish second delay. With a reasonable number of workstations, the above command will start them all in parallel. There are of course other methods to running commands remotely, but this worked well for me.

Source: https://harryjohnston.wordpress.com/2009/12/18/delays-when-connecting-to-windows-7-clients-for-remote-administration/