@echo off if not "%1"=="" goto %1 set GetConnectorVer=1.3 echo. echo GETCONNECTOR.BAT -- Utility to collect OpenDNS Connector service information echo Version %GetConnectorVer% echo Copyright (c) 2015, OpenDNS UK Ltd (Part of Cisco), http://www.opendns.com echo. rem --- This could be improved to check for x86 and x64 set connectordir="C:\Program Files (x86)\OpenDNS\OpenDNS Connector" set TEMPDIR="C:\Windows\temp\GETCONTMP" set LDIFDIR="C:\Windows\temp\GETCONTMP\LDIF" set DIAGDIR="C:\Windows\temp\GETCONTMP\DIAGNOSTICS" set outputfile=%DIAGDIR%\HOST_DIAGNOSTICS.TXT set outputzip=C:\OpenDNS_Diagnostic.zip set tmpfile=%TEMPDIR%\getconnector.tmp set tmpfile2=%TEMPDIR%\getconnector2.tmp set info=%DIAGDIR%\SystemInfo.txt set ntstat=%DIAGDIR%\Netstat.txt set services=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services set tasklist=%DIAGDIR%\tasklistm.txt Set Debuglookup=%DIAGDIR%\Debuglookup.txt Set Tracert=%DIAGDIR%\Tracert.txt Set GPResultz=%DIAGDIR%\GPResultz.txt Set FWInfo=%DIAGDIR%\FWInfo.txt set ConnectorUserInfo=%DIAGDIR%\ConnectorUserInfo.txt set vbsfile=%connectordir%\zipit.vbs rem --- Delete "%TEMPDIR%" if already present if exist rmdir %TEMPDIR% rem --- Delete "C:\GetConnector.zip" if already present if exist del %outputzip% rem --- Create folders mkdir %TEMPDIR% mkdir %LDIFDIR% mkdir %DIAGDIR% echo Gathering information echo Please wait a few moments... call %0 GetDate call %0 GetName call %0 GetIPConfig call %0 GetDNSCache call %0 TaskList call %0 Debuglookup call %0 Traceroute call %0 GetServices call %0 GetSystemInfo call %0 GetNetstat call %0 GetUserInfo call %0 GetGPOInfo call %0 GetFWInfo call %0 GetADInfo call %0 GetOpenDNSDir call %0 tmpfileCleanup call %0 MakeZip call %0 Cleanup goto exit rem -------------------------------------------------------------- rem S U B R O U T I N E S rem -------------------------------------------------------------- rem --- Get date and time information :GetDate echo.|date > %tmpfile% echo.|time >> %tmpfile% find /I "current" < %tmpfile% >> %outputfile% echo. >> %outputfile% echo - Date and time information collected :EndGetDate goto exit :GetName rem --- echo Exporting computer name and OS version start /wait regedit /e %tmpfile% "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName" find """ComputerName""=""" < %tmpfile% >> %outputfile% ver >> %outputfile% echo - Computer name and OS version collected :EndGetName goto exit rem --- Get IP configuration information :GetIPConfig echo. >> %outputfile% echo -------------------- IP Configuration >> %outputfile% ipconfig /all >> %outputfile% echo. >> %outputfile% route print >> %outputfile% echo. >> %outputfile% echo - IP configuration collected :EndGetIPConfig goto exit rem --- Get DNS cache information :GetDNSCache echo. >> %outputfile% echo Get DNS Cache >> %outputfile% ipconfig /displaydns >> %outputfile% echo. >> %outputfile% route print >> %outputfile% echo. >> %outputfile% echo - DNS Cache information collected :EndGetDNSCache goto exit rem --- Get Tasklist :TaskList echo. > %tasklist% tasklist /M > %tasklist% echo - Tasklist information collected :EndTaskList goto exit rem --- Run debug.opendns.com lookup :Debuglookup echo. > %Debuglookup% nslookup -timeout=10 -type=txt debug.opendns.com. 208.67.222.222 > %Debuglookup% 2>&1 nslookup -timeout=10 -type=txt debug.opendns.com. 208.67.220.220 >> %Debuglookup% 2>&1 echo - Debug lookup collected :EndDebuglookup goto exit rem --- Get tracert :Traceroute echo. > %Tracert% echo - Running tracert - this may take a few moments... tracert api.opendns.com. > %Tracert% echo - Traceroute collected :EndTraceroute goto exit rem --- Get list of running services :GetServices if "%os%"=="" goto EndGetServices echo. >> %outputfile% echo -------------------- OPENDNS SERVICES (started) >> %outputfile% echo. >> %outputfile% net start | find /I "OpenDNS" >> %outputfile% echo. >> %outputfile% echo. >> %outputfile% echo -------------------- OTHER SERVICES (started) >> %outputfile% net start > %tmpfile% find /V /I "OpenDNS" < %tmpfile% > %tmpfile2% find /V /I "services are started:" < %tmpfile2% > %tmpfile% find /V /I "The command completed successfully" < %tmpfile% >> %outputfile% echo. >> %outputfile% echo - Running services information collected :EndGetServices goto exit rem --- Get system information :GetSystemInfo if not exist "%systemroot%\system32\systeminfo.exe" goto EndGetSystemInfo systeminfo > %info% echo - System information collected :EndGetSystemInfo goto exit rem --- Get GPO info :GetGPOInfo echo. > %GPResultz% gpresult /Z > %GPResultz% echo - GPO info collected :EndGetGPOInfo goto exit rem --- Get Firewall info :GetFWInfo echo. > %FWInfo% netsh advfirewall show allprofiles > %FWInfo% echo - FW info collected :EndGetFWInfo goto exit rem --- Get Netstat information :GetNetstat ver | find /i "Windows 2000" > nul if errorlevel 1 goto GetNetstat-XP netstat -an > %ntstat% goto EndGetNetstat :GetNetstat-XP netstat -ano > %ntstat% tasklist /v >> %ntstat% echo - Netstat collected :EndGetNetstat-XP :EndGetNetstat goto exit :GetUserInfo rem --- Get OpenDNS_Connector group info dsquery user -samid OpenDNS_Connector | dsget user -memberof -expand > %ConnectorUserInfo% echo - OpenDNS_Connector group membership information collected :EndGetUSerInfo goto exit rem --- Get AD info :GetADInfo ECHO. ECHO Please enter your AD Server's IP address, your AD domain name, ECHO and the password of the OpenDNS_Connector user. ECHO WARNING: this password will be displayed in plaintext and not secure. ECHO If you enter * as your password, you will be prompted 4 times, but the prompt will be masked. ECHO. SET /p AD_IP= IP of AD server? SET /p DOMAIN= AD Domain name? SET /p PASSWORD= Password (will be displayed, or * to be prompted securely)? ECHO. CALL ldifde -s %AD_IP% -b OpenDNS_Connector %DOMAIN% %PASSWORD% -r "(&(objectCategory=person)(objectClass=user))" -l sAMAccountName,memberOf,objectGUID -f %LDIFDIR%\Fresh-UserStruct-Raw.ldif CALL ldifde -s %AD_IP% -b OpenDNS_Connector %DOMAIN% %PASSWORD% -r "(objectClass=organizationalunit)" -l sAMAccountName,memberOf,objectGUID -f %LDIFDIR%\Fresh-OrgStruct-Raw.ldif CALL ldifde -s %AD_IP% -b OpenDNS_Connector %DOMAIN% %PASSWORD% -r "(objectClass=computer)" -l sAMAccountName,memberOf,objectGUID -f %LDIFDIR%\Fresh-CompStruct-Raw.ldif CALL ldifde -s %AD_IP% -b OpenDNS_Connector %DOMAIN% %PASSWORD% -r "(objectClass=group)" -l sAMAccountName,memberOf,objectGUID -f %LDIFDIR%\Fresh-GroupStruct-Raw.ldif ECHO. :EndGetADInfo goto exit rem --- Collect OpenDNS directory structure :GetOpenDNSDir echo Copying OpenDNS files xcopy /e /q %connectordir% %TEMPDIR% echo files copied successfully :EndGetOpenDNSDir goto exit rem --- Clean up tmpfile and tmpfile2 before zippping :tmpfileCleanup if exist %tmpfile% del %tmpfile% if exist %tmpfile2% del %tmpfile2% :EndtmpfileCleanup goto exit rem --- Make Zip File :MakeZip echo "Making zip..." echo Set objArgs = WScript.Arguments > %vbsfile% echo InputFolder = objArgs(0) >> %vbsfile% echo ZipFile = objArgs(1) >> %vbsfile% echo CreateObject("Scripting.FileSystemObject").CreateTextFile(ZipFile, True).Write "PK" ^& Chr(5) ^& Chr(6) ^& String(18, vbNullChar) >> %vbsfile% echo Set objShell = CreateObject("Shell.Application") >> %vbsfile% echo Set source = objShell.NameSpace(InputFolder).Items >> %vbsfile% echo objShell.NameSpace(ZipFile).CopyHere(source) >> %vbsfile% echo wScript.Sleep 2000 >> %vbsfile% CScript %vbsfile% %TEMPDIR% %outputzip% echo. echo Completed. echo. echo ----------------------------------------------------- echo Please send the file %zipfile% to support@opendns.com echo ----------------------------------------------------- :EndMakeZip goto exit :Cleanup rem --- Cleanup temporary directory if exist %TEMPDIR% rmdir /q /s %TEMPDIR% rem --- Cleanup environment variables set connectordir= set TEMPDIR= set LDIFDIR= set DIAGDIR= set outputfile= set outputzip= set tmpfile= set tmpfile2= set info= set ntstat= set services= set tasklist= Set Debuglookup= Set Tracert= Set GPResultz= Set FWInfo= set vbsfile= set ConnectorUserInfo= :EndCleanup rem --- goto exit :exit