Returns resultant set of policy Computer Extension Logging information for a computer. This script contributed by Mike Stephens of Microsoft.

Visual Basic
Edit|Remove
Const FL_FORCE_CREATE_NAMESPACE = 4

strComputer = "."

Set wDate = CreateObject("WbemScripting.SWbemDateTime")
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)

WScript.Echo "Computer Extension Logging"

Set rsopSession = rsopProv.ExecQuery("Select * from  RSOP_ExtensionStatus")

For Each ext In rsopSession
    	WScript.Echo String(50, "=")
    	wDate.Value = ext.beginTime
    	WScript.Echo "Extension: " & ext.DisplayName
    	WScript.Echo "Guid: " & ext.extensionGuid 
    	Select Case ext.loggingStatus
        Case 1
            			WScript.Echo "Status: Logging Successful"
        Case 2
            			WScript.Echo "Status: Logging Incomplete"
        Case 3
            			WScript.Echo "Status: Logging not supported"
	End Select 

	WScript.Echo "Begin Time: " &  FormatDateTime( wDate.GetVarDate() , vbShortDate ) & " " & _
    FormatDateTime( wDate.GetVarDate() , vbShortTime )
	
	wDate.Value = ext.EndTime
	WScript.Echo "End Time: " &  FormatDateTime( wDate.GetVarDate() , vbShortDate ) &  " " &_
    FormatDateTime( wDate.GetVarDate() , vbShortTime )
Next 	

provider.RsopDeleteSession namespaceLocation, hResult