Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

Script to Find DNS Server settings - PART I - please check article at MS web for PART II


Author: Nirmal Sharma

View products that this article applies to.

Summary

You can use below script to find DNS server settings from multiple domain using four authentication sets.

↑ Back to the top


More information

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 (

���������Continued���Please check PART II

↑ Back to the top


Properties

COMMUNITY SOLUTIONS CONTENT DISCLAIMER
MICROSOFT CORPORATION AND/OR ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY, RELIABILITY, OR ACCURACY OF THE INFORMATION AND RELATED GRAPHICS CONTAINED HEREIN. ALL SUCH INFORMATION AND RELATED GRAPHICS ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT AND/OR ITS RESPECTIVE SUPPLIERS HEREBY DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THIS INFORMATION AND RELATED GRAPHICS, INCLUDING ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, WORKMANLIKE EFFORT, TITLE AND NON-INFRINGEMENT. YOU SPECIFICALLY AGREE THAT IN NO EVENT SHALL MICROSOFT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, PUNITIVE, INCIDENTAL, SPECIAL, CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF USE, DATA OR PROFITS, ARISING OUT OF OR IN ANY WAY CONNECTED WITH THE USE OF OR INABILITY TO USE THE INFORMATION AND RELATED GRAPHICS CONTAINED HEREIN, WHETHER BASED ON CONTRACT, TORT, NEGLIGENCE, STRICT LIABILITY OR OTHERWISE, EVEN IF MICROSOFT OR ANY OF ITS SUPPLIERS HAS BEEN ADVISED OF THE POSSIBILITY OF DAMAGES.

↑ Back to the top


Community solutions content disclaimer

Microsoft corporation and/or its respective suppliers make no representations about the suitability, reliability, or accuracy of the information and related graphics contained herein. All such information and related graphics are provided "as is" without warranty of any kind. Microsoft and/or its respective suppliers hereby disclaim all warranties and conditions with regard to this information and related graphics, including all implied warranties and conditions of merchantability, fitness for a particular purpose, workmanlike effort, title and non-infringement. You specifically agree that in no event shall Microsoft and/or its suppliers be liable for any direct, indirect, punitive, incidental, special, consequential damages or any damages whatsoever including, without limitation, damages for loss of use, data or profits, arising out of or in any way connected with the use of or inability to use the information and related graphics contained herein, whether based on contract, tort, negligence, strict liability or otherwise, even if Microsoft or any of its suppliers has been advised of the possibility of damages.

↑ Back to the top


Keywords: KB555980, kbhowto, kbpubtypecca, kbpubmvp

↑ Back to the top

Article Info
Article ID : 555980
Revision : 1
Created on : 9/11/2007
Published on : 9/11/2007
Exists online : False
Views : 425