有没有人知道使用VBScript查找特定GPO的GUID的方法?我已经看过很多从GUID到GPO的例子,但不是相反。
答案 0 :(得分:0)
使用筛选给定显示名称的LDAP查询。 GPO的name
属性包含GUID。
displayName = "..."
domain = GetObject("LDAP://rootDSE").Get("defaultNamingContext")
Set cn = CreateObject("ADODB.Connection")
cn.Provider = "ADsDSOObject"
cn.Open "Active Directory Provider"
Set cmd = CreateObject("ADODB.Command")
Set cmd.ActiveConnection = cn
cmd.CommandText = "SELECT name " & _
"FROM 'LDAP://CN=Policies,CN=System," & domain & "' " & _
"WHERE objectClass = 'groupPolicyContainer' AND " & _
"displayName = '" & displayName & "'"
Set rs = cmd.Execute
Do Until rs.EOF
WScript.Echo rs.Fields("name").Value
rs.MoveNext
Loop