Returns resultant set of policy Policy Setting information for a computer. This script contributed by Mike Stephens of Microsoft.

Visual Basic
Edit|Remove
Const FL_FORCE_CREATE_NAMESPACE = 4

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)

WScript.Echo "Computer RSOP of Policy Settings"

Set colItems = rsopProv.ExecQuery("Select * from RSOP_PolicySetting")

For Each objItem in colItems
    WScript.Echo String(50, "=")
    WScript.Echo "Name: " & objItem.Name
    Wscript.Echo "GPO ID: " & objItem.GPOID
    Wscript.Echo "ID: " & objItem.ID
    Wscript.Echo "Precedence: " & objItem.Precedence
    Wscript.Echo "SOM ID: " & objItem.SOMID
Next

provider.RsopDeleteSession namespaceLocation, hResult