Saturday, May 8, 2010

Troubleshooting Forest Trusts Batch Output

This is one of the batch files I put together to troubleshoot forest trust relationship problems.  It was based off a Microsoft Port Query template batch file.

@echo off
Goto START

************************************************************************
* Created By:  Linda Chapman
* CMD File to facilitate PortQry test for Domain Controllers
* INPUT SYNTAX: OpenPorts.cmd <DC NetBIOS name>
* OUTPUT: This will generate a <DC NetBIOS name>TrustedDomainResults.txt file.
* DEPENDENCY: PortQry.exe
*
************************************************************************

:START
echo.
echo Testing with PortQry against %%s
echo AD/DC specific ports
echo.
echo.

:ERRORCHECK

echo Press any key to continue the test...
pause

:PINGTEST
echo Pinging %%s
Echo    ************* > TrustedDomainResults.txt
Echo    * Ping Test * >> TrustedDomainResults.txt
Echo    ************* >> TrustedDomainResults.txt

for /f "eol=; tokens=1 delims=," %%s in (TrustedDomainServerList.txt) do ping %%s >>TrustedDomainResults.txt
pause
Echo. >> TrustedDomainResults.txt
Echo. >> TrustedDomainResults.txt
echo.
echo.

:PORTWORK
echo Testing DNS
Echo    ************************ >> TrustedDomainResults.txt
Echo    * DNS (53) UDP and TCP * >> TrustedDomainResults.txt
Echo    ************************ >> TrustedDomainResults.txt
Echo    Performing    Portqry -n %%s -p both -e 53
for /f "eol=; tokens=1 delims=," %%s in (TrustedDomainServerList.txt) do Portqry -n %%s -p both -e 53 >>TrustedDomainResults.txt
echo.
echo.
pause
echo Testing Kerberos
Echo    ***************************** >> TrustedDomainResults.txt
Echo    * Kerberos (88) UDP and TCP * >> TrustedDomainResults.txt
Echo    ***************************** >> TrustedDomainResults.txt
Echo     Performing  portqry -n %%s -p both -e 88 >> TrustedDomainResults.txt
for /f "eol=; tokens=1 delims=," %%s in (TrustedDomainServerList.txt) do portqry -n %%s -p both -e 88 >>TrustedDomainResults.txt
echo.
echo.

echo Testing RPC End Point Mapper Service
Echo    ********************************** >> TrustedDomainResults.txt
Echo    * RPC End Point Mapper (135) TCP * >> TrustedDomainResults.txt
Echo    ********************************** >> TrustedDomainResults.txt
echo    performing portqry -n %%s -p TCP -e 135 >> TrustedDomainResults.txt
for /f "eol=; tokens=1 delims=," %%s in (TrustedDomainServerList.txt) do Portqry -n %%s -p TCP -e 135 >>TrustedDomainResults.txt
Echo.   >> TrustedDomainResults.txt
Echo.   >> TrustedDomainResults.txt
echo.
echo.

echo Testing NetBIOS Name Service
Echo    ********************* >> TrustedDomainResults.txt
Echo    * NetBIOS (137) UDP * >> TrustedDomainResults.txt
Echo    ********************* >> TrustedDomainResults.txt
echo   performing portqry -n %%s -p UDP -e 137 >> TrustedDomainResults.txt
for /f "eol=; tokens=1 delims=," %%s in (TrustedDomainServerList.txt) do Portqry -n %%s -p udp -e 137 >>TrustedDomainResults.txt
Echo. >> TrustedDomainResults.txt
Echo. >> TrustedDomainResults.txt
echo.
echo.

echo Testing NetBIOS Datagram Service
Echo    ********************* >> TrustedDomainResults.txt
Echo    * NetBIOS (138) UDP * >> TrustedDomainResults.txt
Echo    ********************* >> TrustedDomainResults.txt
echo    performing portqry -n %%s -p udp -e 138 >> TrustedDomainResults.txt
for /f "eol=; tokens=1 delims=," %%s in (TrustedDomainServerList.txt) do Portqry -n %%s -p udp -e 138 >>TrustedDomainResults.txt
Echo. >> TrustedDomainResults.txt
Echo. >> TrustedDomainResults.txt
echo.
echo.

echo Testing NetBIOS Session Service
echo    ********************* >> TrustedDomainResults.txt
Echo    * NetBIOS (139) TCP * >> TrustedDomainResults.txt
Echo    ********************* >> TrustedDomainResults.txt
echo    performingportqry -n %%s -p tcp -e 139 >> TrustedDomainResults.txt
for /f "eol=; tokens=1 delims=," %%s in (TrustedDomainServerList.txt) do Portqry -n %%s -p tcp -e 139 >>TrustedDomainResults.txt
Echo. >> TrustedDomainResults.txt
Echo. >> TrustedDomainResults.txt
echo.
echo.

echo Testing LDAP
Echo    ************************** >> TrustedDomainResults.txt
Echo    * LDAP (389) UDP and TCP * >> TrustedDomainResults.txt
Echo    ************************** >> TrustedDomainResults.txt
echo    performing portqry -n %%s -p both -e 389 >> TrustedDomainResults.txt
for /f "eol=; tokens=1 delims=," %%s in (TrustedDomainServerList.txt) do Portqry -n %%s -p both -e 389 >>TrustedDomainResults.txt
Echo. >> TrustedDomainResults.txt
Echo. >> TrustedDomainResults.txt
echo.
echo.

echo Testing SMB Direct Hosting
Echo    ***************** >> TrustedDomainResults.txt
Echo    * SMB (445) TCP * >> TrustedDomainResults.txt
Echo    ***************** >> TrustedDomainResults.txt
echo    performing portqry -n %%s -p tcp -e 445 >> TrustedDomainResults.txt
for /f "eol=; tokens=1 delims=," %%s in (TrustedDomainServerList.txt) do Portqry -n %%s -p tcp -e 445 >>TrustedDomainResults.txt
Echo. >> TrustedDomainResults.txt
Echo. >> TrustedDomainResults.txt
echo.
echo.

echo Testing Secure LDAP
Echo    ******************* >> TrustedDomainResults.txt
Echo    * LDAPS (636) TCP * >> TrustedDomainResults.txt
Echo    ******************* >> TrustedDomainResults.txt
echo    portqry -n %%s -p tcp -e 636 >> TrustedDomainResults.txt
for /f "eol=; tokens=1 delims=," %%s in (TrustedDomainServerList.txt) do Portqry -n %%s -p tcp -e 636 >>TrustedDomainResults.txt
Echo. >> TrustedDomainResults.txt
Echo. >> TrustedDomainResults.txt
echo.
echo.

echo Testing GC LDAP
Echo    ******************* >> TrustedDomainResults.txt
Echo    * LDAP (3268) TCP * >> TrustedDomainResults.txt
Echo    ******************* >> TrustedDomainResults.txt
echo    performing portqry -n %%s -p TCP -e 3268 >> TrustedDomainResults.txt
for /f "eol=; tokens=1 delims=," %%s in (TrustedDomainServerList.txt) do Portqry -n %%s -p tcp -e 3268 >>TrustedDomainResults.txt
Echo. >> TrustedDomainResults.txt
Echo. >> TrustedDomainResults.txt
echo.
echo.

echo Testing GC Secure LDAP
Echo    ******************** >> TrustedDomainResults.txt
Echo    * LDAPS (3269) TCP * >> TrustedDomainResults.txt
Echo    ******************** >> TrustedDomainResults.txt
Echo    Test GC SSL (3269) TCP >> TrustedDomainResults.txt
echo    performing portqry -n %%s -p tcp -e 3269 >> TrustedDomainResults.txt
for /f "eol=; tokens=1 delims=," %%s in (TrustedDomainServerList.txt) do Portqry -n %%s -p tcp -e 3269 >>TrustedDomainResults.txt
Echo. >> TrustedDomainResults.txt
Echo. >> TrustedDomainResults.txt
echo.
echo.
echo End of Script
echo pause
Goto END

:END

Published: 4/30/2008 11:39 PM

No comments:

Post a Comment