Wednesday, March 12, 2008

Active Directory Health Check

Echo Performing Active Directory Health Check

IF NOT EXIST "C:\Program Files\Support Tools\" GOTO COPY_SUP_TOOLS

:RUNTOOLS
Echo Running NetDiag Tool..............
netdiag /v /l

Echo Running DCDiag Tool...............
REM dcdiag /e /c /v /f:dcdiag.log

Echo Running RepAdmin Tool.......Displays a list of failed replication events detected by the Knowledge Consistency Checker (KCC).
"c:\Program Files\Support Tools\repadmin /failcache > failcache.txt"

Echo Running RepAdmin Tool.......Returns the server name of the ISTG server for a specified site.
"c:\Program Files\Support Tools\repadmin /istg > istg.txt"

Echo Running RepAdmin Tool.......Displays the amount of time between replications using the ISTG Keep Alive timestamp.
"c:\Program Files\Support Tools\repadmin /latency > latency.txt"

Echo Running RepAdmin Tool.......Displays tasks waiting in the replication queue.
"c:\Program Files\Support Tools\repadmin /queue > queue.txt"

Echo Running RepAdmin Tool.......Displays the connection objects for a specified domain controller. Default is local site.
"c:\Program Files\Support Tools\repadmin /showconn > showconn.txt"

Echo Running RepAdmin Tool.......Displays the replication partners for each directory partition on the specified domain controller. Helps the administrator build a visual representation of the replication topology and see the role of each domain controller in the replication process
"c:\Program Files\Support Tools\repadmin /showrepl > showrepl.txt"

Echo Running RepAdmin Tool.......The replsummary operation quickly and concisely summarizes the replication state and relative health of a forest.
"c:\Program Files\Support Tools\repadmin /replsummary > replsummary.txt"

Echo Running GPOTool Tool.......to check the consistency of Group Policy objects on Domain Controllers.
"c:\Program Files\Support Tools\gpotool /domain:roads.vic.gov.au /checkacl /verbose > gpotool.txt"

Echo Running DNSLint Tool.......DNSLint is a Microsoft Windows utility that helps diagnose common DNS name resolution issues.
"c:\Program Files\Support Tools\dnslint /ad 149.176.18.21 /s 149.176.18.21 /v"

Echo Running Windows Time Service Tool.......used to diagnose problems with Windows Time Service.
"c:\windows\system32\w32tm /monitor > w32tm.txt"

EXIT

:COPY_SUP_TOOLS
MD "C:\Program Files\Support Tools\"
COPY "\\DomainController\NETLOGON\Support Tools" "C:\Program Files\Support Tools"
GOTO RUNTOOLS

Script to Map Network Drives

Script to Map Network Drives

' From the book, "Windows XP Cookbook"
' ISBN: 0596007256
' ------ SCRIPT CONFIGURATION ------

strDrive = "" ' e.g. N:
strPath = "" ' e.g. \\rtp01\c$\temp
strUser = "" ' e.g. AMER\rallen
strPassword = ""
boolPersistent = True ' True = Persistent ; False = Not Persistent
' ------ END CONFIGURATION ---------
set objNetwork = WScript.CreateObject("WScript.Network")
objNetwork.MapNetworkDrive strDrive, strPath, boolPersistent, _
strUser, strPassword
WScript.Echo "Successfully mapped drive"

Script to compare two files

Script to compare two files

' From the book "Windows XP Cookbook"
' ISBN: 0596007256
' ------ SCRIPT CONFIGURATION ------

strFile1 = "file1" ' e.g. c:\scripts\test1.vbs
strFile2 = "file2" ' e.g. c:\scripts\test2.vbs

' ------ END CONFIGURATION ---------
set objFSO = CreateObject("Scripting.FilesystemObject")
set objFile1 = objFSO.opentextfile(strFile1,1)
set objFile2 = objFSO.opentextfile(strFile2,1)
arrFile1 = split(objFile1.ReadAll,vbNewLine)
arrFile2 = split(objFile2.ReadAll,vbNewLine)
objFile1.close
objFile2.close
if ubound(arrFile1) < intlinecount =" ubound(arrFile1)" strerror =" strFile2"> ubound(arrFile2) then
intLineCount = ubound(arrFile2)
strError = strFile2 & " is bigger than " & strFile1
else
intLineCount = ubound(arrFile2)
end if
for i = 0 to intLineCount
if not arrFile1(i) = arrFile2(i) then
exit for
end if
next
if i < (intLineCount + 1) then WScript.Echo "Line " & (i+1) & " not equal" WScript.Echo strError elseif strError <> "" then
WScript.Echo strError
else
WScript.Echo "Files are identical."
end if

Tuesday, March 11, 2008

How to encode VBScripts using MS Script Encoder


How to encode VBScripts using Microsoft Script Encoder


1) To encode a VBScript, you need to install the Microsoft Script Encoder (MSE). You can download MSE from the following site:


2) Once installed, the script encoder can be found in the following directory - "C:\Program Files\Windows Script Encoder\".

3) To encode a VBScript (vbs) to the encoded format (.vbe), open a command prompt and type the following command:

For more information on how to use screnc (Microsoft Script Encoder) tool, please have a look at the following help file.

Saturday, March 8, 2008

Script to check MSI Products installed on a PC

The following code example shows how to generate an inventory list of installed software on a local computer. Please bear in mind this script does not return all software installed on a PC, it ONLY returns the one that were installed using MSI.

'Set computer name - replace variable with appropriate value

Computer = "."


'Obtain collection of Windows Installer packages

Set MSIapps = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & Computer &_ "\root\cimv2").ExecQuery("select * from Win32_Product")


'Obtain number of program in collection

AppList = AppList & MSIapps.Count & " MSI packages installed:" & VBCRLF & "------" & VBCRLF


'Enumerate the names of the packages in the collection

For each App in MSIapps

AppList = AppList & App.Name & VBCRLF

Next

'Display list of MSI packages

Wscript.Echo AppList