Script to Find DNS Server settings.

Script to find DNS settings:

 

  1. You can use up to Four Login attempts to check authentication on different servers or domains.
  2. Results get stored in a CSV format file. File name: Report.CSV
  3. Command window display for script information.
  4. Script supplies error message exactly.
  5. Servers Up/Down Status.

 

 

 

@echo off

 

@echo  =====================================================

@Echo  Script to Find DNS Servers configured for each server

@echo  =====================================================

 

@echo Please Enter Server List Path (e.i. E:\Nirmal\Srvlist\mgmsrv.txt)

 

setlocal enabledelayedexpansion

 

set /P srvlist=” “

 

IF exist %srvlist% (

  Echo Server list found: %srvlist%

  Echo Processing all the servers from %srvlist%

  CLS

 

) ELSE (

  CLS

  Echo Server list NOT found: %srvlist%

  Echo Exiting…

  goto:EOF

 

)

 

  SET DNS_Conf=

  SET Int_Logon=

  SET ComERRSRM=

  SET SNK_login=

  SET ComERRSNK=

  SET AMU_Login=

  SET Fold_Drive=

  SET Fold_Loc=

  SET REG_Upload=

  SET REG_Use=

  SET ServerStat=

  SET LOR_NEW=

  SET LOR_OLD=

  SET DLS_B=

  SET BIAS_B=

  SET DLS_A=

  SET BIAS_A=

  SET Rem_Req=

  SET PSEXEC_SPU=

  SET DST_Stat=

  SET AOS_Ver=

  SET AOS_Folder=

  SET AOS_Un=

  SET Uninst_Fold=

  SET Os_SRMto_E=

  SET Final_login=

  SET ComERR=

  SET NewComERR=

  SET Method_U=

  SET Copy_Un_F=

  SET DST_Source=

  SET DST_Dest=

 

set /a totsrv=0

set /a totcnt=0

 

FOR /F %%a in (%srvlist%) DO SET /a totsrv=!totsrv!+1

 

  SET SNK_login=

  SET Loc_Power=

  SET ComERRSNK=

  SET ComERRSRM=

  SET AMU_Login=

  SET ServerStat=

  SET LOR_NEW=

  SET LOR_OLD=

  SET DLS_B=

  SET Int_Logon=

  SET DNS_Conf=

  SET PSEXEC_TZ=

  SET Rem_Req=

  SET PSEXEC_SPU=

  SET AOS_Ver=

  SET AOS_Folder=

  SET AOS_Un=

  SET Uninst_Fold=

  SET Os_SRMto_E=

  SET Final_login=

  SET ComERR=

  SET NewComERR=

  SET PS_Rem=

  SET Method_U=

  SET Copy_Un_F=

  SET DST_Source=

  SET DST_Dest=

  SET Fold_Drive=

  SET Fold_Loc=

  SET Search_C=

  SET Search_D=

  SET Search_E=

 

Title DNS Server script in Progress…

 

IF exist E:\Nirmal\Dns\Report.csv Del E:\Nirmal\Dns\Report.csv

IF exist E:\Nirmal\Dns\Dnssrv.csv Del E:\Nirmal\Dns\DnsSrv.csv

IF exist E:\Nirmal\Dns\HostsAlive.txt Del E:\Nirmal\Dns\HostsAlive.txt

IF exist E:\Nirmal\Dns\HostsDown.txt Del E:\Nirmal\Dns\HostsDown.txt

IF exist E:\Nirmal\Dns\Alreadydone.txt Del E:\Nirmal\Dns\AlreadyDone.txt

IF exist E:\Nirmal\Dns\ToBeDone.txt Del E:\Nirmal\Dns\ToBeDone.txt

IF exist E:\Nirmal\Dns\RemovedDST.txt Del E:\Nirmal\Dns\RemovedDST.txt

IF exist E:\Nirmal\Dns\RemoveFailed.txt Del E:\Nirmal\Dns\RemoveFailed.txt

IF exist E:\Nirmal\Dns\PSFailed.txt Del E:\Nirmal\Dns\PSFailed.txt

IF exist E:\Nirmal\Dns\PSSuccess.txt Del E:\Nirmal\Dns\PSSuccess.txt

 

Echo Server Name, Up/Down, LOR-New Login, LOR-Old Login, SRM-Login?, SRMSNK Login?, Final Login?, PSEXEc, PSEXEC Remark, OS Version, DNS Servers Configured, Error REMARK-LOR New Login, Error REMARK – LOR Old Login, Error REMARK – SRM Login, Error REMARK – SRMSNKING Login >> Report.csv

REM Echo Server Name, DNS Configuration, >> DnsSrv.csv

 

FOR /F “TOKENS=*” %%a IN (%srvlist%) DO CALL:DONOW “%%a”

 

:DONOW

 

SET srvname=%~1

 

REM Echo %srvname%, >> Dnssrv.csv

 

IF [%OldSrv%] == [] SET OldSrv=%srvname%

 

SET /a totcnt=%totcnt%+1

 

CLS

 

Echo 1.Processing Server: %srvname% Total Server:[%totcnt% Of %totsrv%] Last Server: %OldSrv%

Echo 2.Checking Connectivity……………

 

IF exist E:\Nirmal\Dns\pingresult.txt Del E:\Nirmal\Dns\pingresult.txt

 

Ping -n 1 %srvname% > PingResult.txt 2>&1

 

FIND /i “Reply From” < PingResult.txt > DoNotShow.txt 2>&1

 

IF %errorlevel% == 0 (

 

  SET ServerStat=UP

 

  Echo 3.Reply received from Host %srvname%

  Echo %srvname% >> HostsAlive.txt

 

  REM This is to check wether currently logged in user have access or not.

 

  IF exist E:\Nirmal\Dns\Access.txt Del E:\Nirmal\Dns\Access.txt

  IF exist E:\Nirmal\Dns\NoAccess.txt Del E:\Nirmal\Dns\NoAccess.txt

 

  Echo 4.Checking Access for Currently Logged on user on Server: %srvname%

 

  DIR \\%srvname%\C$ > Access.txt 2>&1

 

  FIND /i “File(s)” < Access.txt > DoNotShow.txt

 

  IF !errorlevel! NEQ 0 (

 

     FOR /F “Tokens=*” %%T In (‘Type Access.txt’) DO SET NewComERR=”%%T”

 

     IF exist E:\Nirmal\Dns\LORold.txt Del E:\Nirmal\Dns\LORold.txt

 

     Echo 5.LOR New login failed…checking LOR Old password

 

     NET USE T: /delete > DoNotShow.txt 2>&1

     NET USE T: \\%srvname%\c$ /user:LORtest password > LOROld.txt 2>&1

    

     FIND /i “The command completed successfully.” < LORold.txt > DoNotShow.txt 2>&1

 

     IF !errorlevel! NEQ 0 (

            

        Echo 6.LOR Old password also failed…

        SET LOR_Old=Failed

        SET LOR_New=Failed

        SET Final_Login=Failed

  

        FOR /F “Tokens=*” %%T In (‘Type LORold.txt’) DO SET ComERR=”%%T”

 

        IF exist E:\Nirmal\Dns\SRMLogin.txt Del E:\Nirmal\Dns\SRMLogin.txt

 

        Echo 5.LOR Old login failed…checking SRM Login

 

        NET USE T: /delete > DoNotShow.txt 2>&1

        NET USE T: \\%srvname%\c$ /user:SRM\nsharma27 Password2006 > SRMLogin.txt 2>&1

    

        FIND /i “The command completed successfully.” < SRMLogin.txt > DoNotShow.txt 2>&1

 

        IF !errorlevel! NEQ 0 (

 

           Echo 7.SRM Login also failed…

 

           SET LOR_Old=Failed

           SET LOR_New=Failed

           SET AMU_Login=Failed    

           SET Final_Login=Failed

    

           FOR /F “Tokens=*” %%T In (‘Type SRMLogin.txt’) DO SET ComERRSRM=”%%T”

 

           IF exist E:\Nirmal\Dns\SNKlogin.txt Del E:\Nirmal\Dns\SNKLogin.txt

 

           Echo 5.SRM Login also failed…checking SRMSNKING Login…

 

           NET USE T: /delete > DoNotShow.txt 2>&1

           NET USE T: \\%srvname%\c$ /user:SRMSNKING\nsharma27 Password2006 > SNKLogin.txt 2>&1

    

           FIND /i “The command completed successfully.” < SNKLogin.txt > DoNotShow.txt 2>&1

 

           IF !errorlevel! NEQ 0 (

      

              Echo 7.SRM Login also failed…

 

              SET LOR_Old=Failed

              SET LOR_New=Failed

              SET AMU_Login=Failed    

              SET SNK_login=Failed

              SET Final_Login=Failed

          

              FOR /F “Tokens=*” %%T In (‘Type SNKLogin.txt’) DO SET ComERRSNK=”%%T”

 

           ) ELSE (

 

              SET ComERRSNK=

              Echo 7.SNKING Login passed…

        

              SET LOR_Old=Failed

              SET LOR_New=Failed

              SET AMU_Login=Failed

              SET SNK_login=Passed

              SET Final_Login=Passed

           )

 

        ) ELSE (

 

           SET ComERRSRM=

           Echo 7.SRM Login passed…

        

           SET LOR_Old=Failed

           SET LOR_New=Failed

           SET AMU_Login=Passed

           SET Final_Login=Passed

        )

 

     ) ELSE (

  

        SET ComERR=

               

        Echo 6.LOR Old password Passed…

        SET LOR_New=Failed

        SET LOR_old=Passed

        SET Final_Login=Passed

     )

 

  ) ELSE (

    

     SET NewComERR=

 

     Echo 5.Currently Logged on user have access…

     Echo 6.LOR New SRMthentication passed…

 

     SET LOR_New=Passed

     SET Final_Login=Passed

     SET LOR_Old=Not Checked

  )     

 

  IF !Final_Login! == Failed (

    

     SET DLS_B=

     SET BIAS_B=

     SET DLS_A=

     SET BIAS_A=

     SET TimeZone_N=

     SET PSEXEC_TZ=

     SET Rem_Req=

     SET AOS_Ver=

     SET AOS_Folder=

     SET AOS_Un=

     SET PSEXEC_SPU=

     SET Uninst_Fold=

     SET Os_SRMto_E=

 

     Echo 5.Login Failed…user DON’T have access to copy DST Folder.

    

     Echo %srvname% >> NoAccess.txt

 

  ) ELSE (

 

     Echo 5.Currently Logged in user have access on C:\ drive.

 

     Echo 6.Check OS Version and Windows System Folder name…

 

     IF exist E:\Nirmal\Dns\Windir.txt Del E:\Nirmal\Dns\Windir.txt

     IF exist E:\Nirmal\Dns\UnFold.txt Del E:\Nirmal\Dns\UnFold.txt

 

     Psexec.exe \\%srvname% cmd.exe /c SET > Windir.txt 2>&1

    

     FIND /i “windir=C:\WINDOWS” < Windir.txt > DoNotShow.txt 2>&1

 

     IF !errorlevel! == 0 (

        

      SET AOS_Ver=”Windows 2003″

        Echo 6.OS Version: !AOS_Ver!

 

     ) ELSE (

       

        SET AOS_Ver=”Windows 2000″

        Echo 6.OS Version: !AOS_Ver! 

 

     )

 

     IF exist E:\Nirmal\Dns\Dns.txt Del E:\Nirmal\Dns\Dns.txt

     IF exist E:\Nirmal\Dns\Othdns.txt Del E:\Nirmal\Dns\Othdns.txt

 

     Psexec.exe \\%srvname% Ipconfig /all > Dns.txt 2>&1

 

     Find /i “DNS Servers” < Dns.txt > Othdns.txt 2>&1

     FOR /F “Tokens=*” %%a IN (Othdns.txt) DO SET DNS_CONF=%%a

  

   

REM FOR /F “Tokens=*” %%a IN (othdns.txt) DO (

 

REM         SET DNS_Conf=

REM       SET DNS_Conf=%%a

REM          Echo ,!DNS_Conf!, >> DnsSrv.csv

        

REM   )

  

 

   )

 

) ELSE (

 

  SET ServerStat=Down

 

  Find /i “Request Timed” < PingResult.txt > DoNotShow.txt

 

  IF !errorlevel! == 0 (

     SET ServerStat=Request Timed Out

  ) ELSE (

     SET ServerStat=Uknown Host

  )

 

  SET LOR_NEW=

  SET LOR_OLD=

  SET DLS_B=

  SET BIAS_B=

  SET DLS_A=

  SET BIAS_A=

  SET TimeZone_N=

  SET PSEXEC_TZ=

  SET Rem_Req=

  SET PSEXEC_SPU=

  SET DST_Stat=

  SET AOS_Ver=

  SET AOS_Folder=

  SET AOS_Un=

  SET Uninst_Fold=

  SET Os_SRMto_E=

  SET DNS_Conf=

  SET DST_Stat=NotOk

  SET Rem_Req=

  SET ComERR=

  SET NewComERR=

  SET PS_Rem=

  SET REG_Use=

  SET Method_U=

  SET REG_Upload=

  SET Copy_Un_F=

  SET DST_Source=

  SET DST_Dest=

  SET Fold_Drive=

  SET Fold_Loc=

  SET Search_C=

  SET Search_D=

  SET Search_E=

  SET AMU_Login=

  SET ComERRSRM=

  SET Int_Logon=

  SET Loc_Power=

  SET SNK_login=

  SET ComERRSNK=

 

  Echo %srvname% >> HostsDown.txt

  Echo 3.Reply NOT received from Host %srvname%

 

)

 

SET OldSrv=%srvname%

 

IF [!srvname!] == [] (

 

  Echo Empty

 

) ELSE (

 

ECHO %srvname%, %ServerStat%, %LOR_NEW%, %LOR_OLD%, %AMU_Login%, %SNK_login%, %Final_Login%, %PSEXEC_TZ%, %PS_Rem%, %AOS_Ver%, %Dns_conf%, %NewComERR%, %ComERR%, %ComERRSRM%, %ComERRSNK%, >> Report.csv

 

  SET ServerStat=Down

  SET Final_login=

  SET LOR_NEW=

  SET Int_Logon=

  SET LOR_OLD=

  SET DLS_B=

  SET BIAS_B=

  SET DLS_A=

  SET BIAS_A=

  SET TimeZone_N=

  SET PSEXEC_TZ=

  SET Rem_Req=

  SET AOS_Ver=

  SET AOS_Folder=

  SET AOS_Un=

  SET Uninst_Fold=

  SET DNS_Conf=

  SET Os_SRMto_E=

  SET DST_Stat=NotOk

  SET Rem_Req=Yes

  SET ComERR=

  SET NewComERR=

  SET PS_Rem=

  SET Method_U=

  SET REG_Use=

  SET REG_Upload=

  SET Copy_Un_F=

  SET DST_Source=

  SET DST_Dest=

  SET Fold_Drive=

  SET Fold_Loc=

  SET Search_C=

  SET Search_D=

  SET Search_E=

  SET AMU_Login=

  SET ComERRSRM=

  SET SNK_login=

  SET ComERRSNK=

  SET Loc_Power=

  

)

 

:eof

 

Citrix Presentation Server 4.0 issue with Windows 2003

Couples of forums are going through an issue for Citrix Presentation Server 4.0. This issue is related to Citrix and Microsoft both. Windows is causing a STOP error on servers having Citrix Presentation Server installed. This is caused because of a conflict between Win32k.sys and WDICA.sys module of Citrix.

Currently Citrix is handling all the cases one by one and then supply a private hotfix as the replacement of WDICA.sys file. We have suffered the same and after analyzing the dump, we have found that WDICA.sys and Win32k.sys are conflicting with each other. We have unexpected shutdown on many of our production server on which Cirix Presentation Server 4.0 is installed. After analyzing memory dumps we have found that this is being caused by WDICA.sys and Win32k.sys system modules. WDICA.sys is the module being used by Citrix application and responsible for communication between Citrix Server and ICA Client. Win32k.sys is the Windows Kernel module and always active to process requests coming from other sub-components of Kernel. There was a page fault at the following address for WDICA.sys driver/module:

1. 91c84184 8082cffc 0000008e c0000005 8087bb96 nt!KeBugCheckEx+0x1b

2. 91c84548 808896e2 91c84564 00000000 91c845b8 nt!KeTerminateThread+0xee2 Thread terminated unexpectedly !

3. 91c845c8 80830e58 91c84628 8b371100 80892853 nt!Kei386EoiHelper+0x1d2

4. 91c8462c f4515208 0000000c f4515526 878b4000 nt!ZwYieldExecution+0x1

9f8 91c84668 f4515907 878b4000 91c8468c 00000000 WDICA+0x12208 91c84684 f451621e 00000200 91c846d8 88539ff8 WDICA+0x12907 91c8469c f4516500 878b4000 f452627a 878b4000 WDICA+0x1321e 00000000 00000000 00000000 00000000 00000000 WDICA+0x13500

After analyzing DC (memory area: 1,2,3,4) of module in memory.dmp generated by servers, I have found that one of the function from WDICA.sys replaced the memory area forcefully (because both the process/threads run in higher priority so anyone can replace each others memory area) used by Kernel module (Win32k.sys) and this resulted in termination of all the threads of Win32k.sys. Since Win32k.sys is a Kernel component, any termination in Kernel thread results in system crash or STOP error. After digging more into this, I found that this is an issue with both the modules. The new functions in Citrix module are conflicting with Win32k.sys while shadowing a user session from one Citrix server to another Citrix server. Users keep shadowing session for their purpose and after about 2-3 minutes one of the servers reboots with STOP error.

Solution and couple of points:

1. Its happening because of the two modules: Win32k.sys and WDICA.sys. Probably replacing WDICA.sys should be okay for now but its good to replace Win32k.sys too. A hotfix from Microsoft is available to replace the Win32k.sys module. Please note: Win32k.sys replacement is part of Service Pack 2 and Microsoft recommends to upgrade its product with latest version but one can obtain Wn32k.sys separately from Microsoft.

http://support.microsoft.com/kb/907966

2. For WDICA.sys – You should contact Citrix to obtain the old version of WDICA.sys module. The file version must be 4.0.2198.1.

3. It started since when Hotfix replaced the module WDICA.sys with latest version.

4. It happens when shadowing a user on another server. For example, Administrator is on Citrix1 shadowing a user on Citrix2 and after 2-5 minutes Citrix2 reboots with STOP error.