portqry script

Looking to create a simple script that looks for all the servers in a srvs.txt and runs a report of which ports are open

Something like this - or better :)
for /f %%i in (svrs.txt) do portqry -n %%i -r 1:65535 -p both -l portlogfile.txt

The Goal is to make sure all the AD ports are open between DC's

TCP/UDP port 53 DNS
TCP/UDP port 88 for Kerberos Authentication
UDP 123 Windows Time
TCP 135 for RPC
UDP 137  For User and Computer Authentication
UDP 138  DFS, Group Policy
TCP/UDP 389 for LDAP
TCP/UDP 445 for SMB/CIFS/SMB2
TCP 636 LDAP SSL
TCP/UDP Dynamic - 1025 to 5000 ( Windows Server 2003)
TCP Port 3268 & 3269 for Global Catalog
TCP 5722  File Replication ( RPC, DFSR ( SYSVOL)
TCP/UDP Dynamic 49152 to 65535  for DCOM, RPC, EPM
newbie2239Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Randy DownsOWNERCommented:
Try this.

@ECHO OFF
:: NAME: DCPortTest.CMD v1.0
:: DATE: 03/29/2009
:: PURPOSE:  Test connectivity from one DC to one or more remote DCs
:: using PORTQRY utility. 
:: The SERVERS.TXT contains a list of servers (one server per line)
:: to check connectivity to.


ECHO     DATE: %DATE% > DC_PORTQRY.TXT
ECHO     TIME: %TIME% >> DC_PORTQRY.TXT
ECHO     USER: %USERNAME% >> DC_PORTQRY.TXT
ECHO COMPUTER: %COMPUTERNAME% >> DC_PORTQRY.TXT
ECHO. >> DC_PORTQRY.TXT
ECHO. >> DC_PORTQRY.TXT
ECHO. >> DC_PORTQRY.TXT
FOR /F "tokens=1" %%i in (servers.txt) DO (
 ECHO ::::::::::::::::::::::  %%i  :::::::::::::::::::::::::: >> DC_PORTQRY.TXT 
 ECHO Testing %%i
 ECHO. >> DC_PORTQRY.TXT 
 PORTQRY -n %%i -e 88 -p TCP | findstr /i "88"  >> DC_PORTQRY.TXT 
 PORTQRY -n %%i -e 445 -p TCP | findstr /i "445" >> DC_PORTQRY.TXT 
 PORTQRY -n %%i -e 389 -p TCP | findstr /i "389" >> DC_PORTQRY.TXT 
 PORTQRY -n %%i -e 3268 -p TCP | findstr /i "3268"  >> DC_PORTQRY.TXT 
 PORTQRY -n %%i -e 135 -p TCP | findstr /i "135" >> DC_PORTQRY.TXT
 ECHO. >> DC_PORTQRY.TXT  
 ECHO. >> DC_PORTQRY.TXT  
)

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.