Does anyone know of a way to find the GUID of a specific GPO given its name using VBScript? I've seen a lot of examples to go from a GUID to a GPO, but not the other way around.
问问题
472 次
1 回答
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
于 2014-12-17T19:02:23.460 回答