Active Directory Health Diagnostics Batch Code

Hello to all,

Most of my friends are asking about the health check and the tool to do that in Active Directory domains so I have added the code to build a batch file. Copy below codes and paste it into a notepad then save it as a *.bat file and you are ready to run. The code contains several syntax for testing the Active Directory so I must say you need a log file as a test result so I placed c:\Active_Directory_Health_Diagnostic_LOG.txt as a result log file. This file can be written in doc so it can be read in MS Word. Just remove .txt and replace .doc in that line. The log file will be created in C:\ drive.

@echo off
echo Active Directory Health Diagnostic by Sachin Jung Karki
echo ………………………………….
echo Running dcdiag /v…..
dcdiag /v >> c:\Active_Directory_Health_Diagnostic_LOG.txt
echo Running dcdiag /test:DNS /DNSALL (Checking all DNS, this may take a few moments, please be patient)…..
dcdiag /test:DNS /DNSALL /e /v >> c:\Active_Directory_Health_Diagnostic_LOG.txt
echo Running dcdiag /test:DcPromo /e /v…..
dcdiag /test:DcPromo /e /v >> c:\Active_Directory_Health_Diagnostic_LOG.txt
echo Running dcdiag /test:RegisterInDNS…..
dcdiag /test:RegisterInDNS >> c:\Active_Directory_Health_Diagnostic_LOG.txt
echo Running netdiag.exe /v…..
netdiag.exe /v >> c:\Active_Directory_Health_Diagnostic_LOG.txt
echo Running netsh dhcp show server…..
netsh dhcp show server >> c:\Active_Directory_Health_Diagnostic_LOG.txt
echo Running repadmin /showreps…..
repadmin /showreps >> c:\Active_Directory_Health_Diagnostic_LOG.txt
echo Running repadmin /replsum /errorsonly…..
repadmin /replsum /errorsonly >> c:\Active_Directory_Health_Diagnostic_LOG.txt
echo ………………………………….
echo Diagnostic Completed Successfully…
echo view results in C:\Active_Directory_Health_Diagnostic_LOG.txt
pause
echo ………………………………….
echo ………………………………….
echo ………………………………….
echo General Health Ratio (FAILS/PASSES)
echo THis is a general Active Directory Health Diagnostic, be sure to check C:\Active_Directory_Health_Diagnostic_LOG.txt for Log File
echo ………………………………….
echo NUMBER OF FAILS
find /c /i “fail” c:\Active_Directory_Health_Diagnostic_LOG.txt
echo ………………………………….
echo NUMBER OF PASSES
find /c /i “pass” c:\Active_Directory_Health_Diagnostic_LOG.txt
pause
nslookup

================================================================

@echo off
echo Active Directory Health Diagnostic by Sachin Jung Karki
echo ………………………………….
echo Running dcdiag /v…..
dcdiag /v >> c:\Active_Directory_Health_Diagnostic_LOG.doc
echo Running dcdiag /test:DNS /DNSALL (Checking all DNS, this may take a few moments, please be patient)…..
dcdiag /test:DNS /DNSALL /e /v >> c:\Active_Directory_Health_Diagnostic_LOG.doc
echo Running dcdiag /test:DcPromo /e /v…..
dcdiag /test:DcPromo /e /v >> c:\Active_Directory_Health_Diagnostic_LOG.doc
echo Running dcdiag /test:RegisterInDNS…..
dcdiag /test:RegisterInDNS >> c:\Active_Directory_Health_Diagnostic_LOG.doc
echo Running netdiag.exe /v…..
netdiag.exe /v >> c:\Active_Directory_Health_Diagnostic_LOG.doc
echo Running netsh dhcp show server…..
netsh dhcp show server >> c:\Active_Directory_Health_Diagnostic_LOG.doc
echo Running repadmin /showreps…..
repadmin /showreps >> c:\Active_Directory_Health_Diagnostic_LOG.doc
echo Running repadmin /replsum /errorsonly…..
repadmin /replsum /errorsonly >> c:\Active_Directory_Health_Diagnostic_LOG.doc
echo ………………………………….
echo Diagnostic Completed Successfully…
echo view results in C:\Active_Directory_Health_Diagnostic_LOG.doc
pause
echo ………………………………….
echo ………………………………….
echo ………………………………….
echo General Health Ratio (FAILS/PASSES)
echo THis is a general Active Directory Health Diagnostic, be sure to check C:\Active_Directory_Health_Diagnostic_LOG.doc for Log File
echo ………………………………….
echo NUMBER OF FAILS
find /c /i “fail” c:\Active_Directory_Health_Diagnostic_LOG.doc
echo ………………………………….
echo NUMBER OF PASSES
find /c /i “pass” c:\Active_Directory_Health_Diagnostic_LOG.doc
pause
nslookup

I hope this information will help you.