В. Как получить список всех объектов групповой политики (GPO) в группе с помощью сценария?

О.

' Убедитесь, что указаны все необходимые аргументы.
If Wscript.Arguments.Count < 1 Then 
Wscript.Echo "Arguments  required. For example:" & vbCrLf _ 
  & "cscript searchgpo.vbs dc=savilltech,dc=com" 
Wscript.Quit(0) 
End If 
  
strRootSearch = Wscript.Arguments(0) 
  
Set objConnection = CreateObject("ADODB.Connection") 
objConnection.Open "Provider=ADsDSOObject;" 
  
Set objCommand = CreateObject("ADODB.Command") 
objCommand.ActiveConnection = objConnection 
  
objCommand.CommandText = _ 
"
">;(&(objectCategory=groupPolicyContainer))" & _ 
  ";name,displayName;subtree" 
  
Set objRecordSet = objCommand.Execute 
  
If objRecordset.RecordCount = 0 Then 
    WScript.Echo "No Group Policy Objects Found" 
Else 
    objRecordSet.MoveFirst 
    Do Until objRecordSet.EOF 
        Wscript.Echo "GUID: " & objRecordSet.Fields("name").Value & " 
Name: " & 
        objRecordSet.Fields("displayName").Value 
        objRecordSet.MoveNext 
    Loop 
End If 
  
objConnection.Close 
Образец выполнения и результаты:
D:Temp>cscript listgpo.vbs dc=savilltech,dc=com 
  
GUID: {31B2F340-016D-11D2-945F-00C04FB984F9} Name: Default Domain 
Policy 
GUID: {6AC1786C-016F-11D2-945F-00C04fB984F9} Name: Default Domain 
Controllers Po 
licy 
GUID: {A9AB07C1-5EAA-4E60-9507-F33524933E7A} Name: Restrict Account 
Rights 
GUID: {CE948635-2E6E-4AAB-8F46-5CA7581528AF} Name: Remove Service 
Account Rights 
  
GUID: {01D59D61-5417-45A7-96B3-9F694CC686C0} Name: Auto Enrollment 
GUID: {BA7E1B25-7341-471E-8FEC-17B9E761DB35} Name: Autoenrollment 
GUID: {9A0C4F9C-C079-4929-AED0-BBBEB590EAA8} Name: Service Delegation 
GUID: {A2EA6C62-C8E4-4C2F-9F7F-9339B2F73451} Name: Terminal Server 
Session 
  Directory
GUID: {2B91B2AD-B174-4254-8142-F86432F02A79} Name: Block IE7
GUID: {E48AF63C-F8EE-41C6-B943-175B1B5EAF93} Name: DisplaySetting1
GUID: {D5BB4DC1-3270-4992-B5BC-E9B55A874347} Name: DisplaySetting2
GUID: {EAB0039E-A677-4C89-9CF2-053576CDA1FC} Name: Deploy Printers