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

Advertisements

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
jectCategory=person)(objectclass=user)(objectSid=*)(!samAccountType:1.2.840.1135
56.1.4.804:=3))(&(objectCategory=person)(!objectSid=*))(&(objectCategory=group)(
groupType:1.2.840.113556.1.4.804:=14)))(objectCategory=user)(|(sn=*)(givenName=*
)(middleName=*)(personalTitle=*)(title=*)(employeeID=*)(company=*)(department=*)
(mail=*)(homePostalAddress=*)(st=*)(streetAddress=*)(postalcode=*)(telephonenumb
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.