Script to find DNS settings:
�
- You can use up to Four Login attempts to check authentication on different servers or domains.
- Results get stored in a CSV format file. File name: Report.CSV
- Command window display for script information.
- Script supplies error message exactly.
- 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 (
�
���������
Continued���Please check PART II