Scheduled Task Information

The following script connects to all servers within the domain and displays information for all scheduled tasks. This script is useful for identifying tasks that are running as service accounts during password changes.

strNamingContext = “defaultNamingContext”
strConnectionString = “Provider=ADsDSOObject”
strFilter= “ObjectCategory=’computer’ and OperatingSystem=’Windows*Server*’”

‘[Functions] ****************************************

Function removeCN(inputString)
Dim textValue
textValue = inputString
Dim textLength
textLength = Len(textValue)
textValue = Right(textValue, textLength-3)

removeCN = textValue
End Function

‘****************************************************

Set objAdRootDSE = GetObject(”LDAP://RootDSE“)
Set objRS = CreateObject(”ADODB.RecordSet”)

objNamingContext = objAdRootDSE.Get(strNamingContext)

strSQLQuery = “SELECT * FROM ‘LDAP://” & objNamingContext &_
“‘ WHERE ” & strFilter

objRS.Open strSQLQuery, strConnectionString

On Error Resume Next

Do until objRS.eof
Set objServer = GetObject(objRS.Fields.Item(0))
strComputer = removeCN(objServer.Name)

Set objWMIService = GetObject(”winmgmts:\\” & strComputer & “\root\cimv2″)
If Err.Number <> 0 Then
WScript.Echo strComputer & “, ERROR Connecting to Object, ” & Err.Description
Else
WScript.Echo strCommputer & ” [connected]”
End if

Set colItems = objWMIService.ExecQuery(”Select * from Win32_ScheduledJob”)
For Each objJob in colItems
strTemp = strComputer & “,” & objJob.JobID

For Each objProp in objJob.Properties_
strTemp = strTemp & “,” & objProp.Value
Next

WScript.Echo strTemp
Next
Set Err = Nothing
objRS.MoveNext
Loop

Powered by WordPress with [GimpStyle]
Entries and comments feeds.