Returns resultant set of policy computer Group Policy script execution times. This script contributed by Judith Herman of Microsoft.

Visual Basic
Edit|Remove
Const FL_FORCE_CREATE_NAMESPACE = 4

Function WMIDateToString(dtmDate)

WMIDateToString = (Mid(dtmDate, 5, 2) & "/" & _
                  Mid(dtmDate, 7, 2) & "/" & _
                  Left(dtmDate, 4) & " " & _
                  Mid(dtmDate, 9, 2) & ":" & _
                  Mid(dtmDate, 11, 2) & ":" & _
                  Mid(dtmDate, 13, 2))

End Function


strComputer = "."

Set locator = CreateObject("WbemScripting.SWbemLocator")

Set connection = locator.ConnectServer( strComputer, "root\rsop", null,null, null, null, 0, null)

Set provider = connection.Get("RsopLoggingModeProvider")

provider.RsopCreateSession FL_FORCE_CREATE_NAMESPACE, Null, namespaceLocation, hResult, eInfo

Set rsopProv = locator.ConnectServer _
    (strComputer, namespaceLocation & "\Computer", null, null, null, null, 0 , null)

Set colItems = rsopProv.ExecQuery("select * from RSOP_ScriptPolicySetting")

For Each objItem in colItems

    WScript.Echo String(50, "=")
    Wscript.Echo "GPO Name: " & objItem.name

    arrScriptList = objItem.ScriptList

    For Each objScript in arrScriptList

       WScript.Echo 
       WScript.Echo vbTab & "Script: " & objScript.script

       Select Case objItem.scriptType
           Case 3
                WScript.Echo vbTab & "Type: Startup"
           Case 4
                WScript.Echo vbTab & "Type: shutdown"
       End Select

       WScript.Echo vbTab & "Arguments: " & objScript.arguments

       WScript.Echo vbTab & "Execution Time: " & WMIDateToString(objScript.executiontime)

       WScript.Echo

    Next 

Next

provider.RsopDeleteSession namespaceLocation, hResult