Monitoring Service In Windows

Below script would monitor the service states ( start, stop, starting , stopping, paused). This script would be useful for system engineers who are using custom utilities to monitor windows services eg: Nagios


Working Script

strComputer = “.”
‘ You need to specify the program( you can get the exe by right click the service –> path to executable.
strProgram = “lsass.exe”

Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\” _
& strComputer & “\root\cimv2”)

‘ Below code checks the program state
Set colProcesses = objWMIService.ExecQuery _
(“SELECT * FROM Win32_Process WHERE Name = ‘” & strProgram & “‘”)
If (colProcesses.Count <> 0) Then
Wscript.Echo “The program is running on the computer”
End If

Adfind Retrieve User Information

Hi All,

Below script will retrieve user’s information from specific OU and export the data to .csv file. In order to run this script , you have to modify the DN matching to your domain
Eg: “ou=test,ou=users,ou=fin,dc=texx,dc=local

Working Script

C:\>adfind.exe -f “(&(&(|(&(ob
er=*)(mobile=*)(manager=*)(description=*))))” -b “ou=test,ou=users,ou=fin,d
c=texx,dc=local” -csv -nodn sn givenname middlename personaltitle title emp
loyeeID company department mail homepostaladdress st streetaddress postalcode te
lephonenumber mobile manager description>>c:\ldif\final.csv

You can modify the .csv file by importing into Microsoft excel.