List_GPOs_and_Links.wsf (In the book)

Download file: list_gpos_and_links.wsf (2 Kb)

<job>
<comment>
Script : List_GPOs_and_Links.wsf
From the book "Group Policy" by Jeremy Moskowitz

The contents of this script are provided "as is".
No warranty of any kind, either express or implied, is made in relation
to the availability, accuracy, reliability or content of this script.
ALWAYS test scripts before using in your production network!
</comment>
<script language="VBScript" src="/GPMgmt.vbs"/>
<script>
CheckCScript
CreateGPMObjects
Set gpmSitesContainer = gpm.GetSitesContainer(dnsForestRoot,"","",gpmConstants.UsePDC)
Set gpmSearchCriteria = gpm.CreateSearchCriteria()
Set somSearchCriteria = gpm.CreateSearchCriteria()
Set GPO_List = gpmDomain.SearchGPOs(gpmSearchCriteria)

WScript.Echo "The following list contains GPOs in the " & gpmDomain.Domain & " domain, the containers linked to them, and their inheritance settings:" & VbCrLf
For Each GPO In GPO_List

WScript.Echo GPO.DisplayName

WScript.Echo String(40,"-")
set somSearchCriteria = gpm.CreateSearchCriteria()
somSearchCriteria.Add gpmConstants.SearchPropertySOMLinks, gpmConstants.SearchOpContains, gpo

Set SOM_List = gpmDomain.SearchSOMs(somSearchCriteria)

If SOM_List.Count <> 0 Then
For Each SOM In SOM_List
WScript.Echo SOM.Name _
& " (Type - " & ConvertSOMType(SOM.Type) & ")" _
& " (Inheritance Blocked? " & SOM.GPOInheritanceBlocked & ")"
Next

Set siteSOM_List = gpmSitesContainer.SearchSites(somSearchCriteria)

For Each SOM In siteSOM_List
WScript.Echo SOM.Name _
& " (Type = " & ConvertSOMType(SOM.Type) & ")" _
& " (Inheritance Blocked? " & SOM.GPOInheritanceBlocked & ")"
Next

Else
WScript.Echo vbTab & "No links to this GPO."
End If
WScript.Echo vbCr
Next

WScript.Echo "Completed GPO link search. Starting WMI Filter link search..."

Set wmiSearchCriteria = gpm.CreateSearchCriteria()
Set wmi_Filter_List = gpmDomain.SearchWMIFilters(wmiSearchCriteria)

If wmi_Filter_List.Count <> 1 Then
plural = "s"
Else
plural = ""
End If
WScript.Echo "The " & gpmDomain.Domain & " domain has " & wmi_Filter_List.Count & " WMI filter" & plural & "."
WScript.Echo vbNL

For Each WMI_Filter In wmi_Filter_List
With WMI_Filter
WScript.Echo .Name & " (" & .Description & ")"
WScript.Echo String(Len(.Name)+ Len(.Description) + 3,"-")
End With

Set gpoSearchCriteria = gpm.CreateSearchCriteria()
gpoSearchCriteria.Add gpmConstants.SearchPropertyGPOWMIFilter, gpmConstants.SearchOPEquals, WMI_Filter

Set Linked_GPO_List = gpmDomain.SearchGPOs(gpoSearchCriteria)
If Linked_GPO_List.Count = 0 Then
WScript.Echo "No GPOs are linked to this WMI Filter."
Else
For Each GPO In Linked_GPO_List
WScript.Echo "Linked to: " & GPO.DisplayName
Next
End If
WScript.Echo vbNL
Next
</script>
</job>
 

Be a hero! Report a problem with this web page here

Event Calendar

Find out where and when Jeremy will be speaking next.

November 2008
SMTWTFS
1
2345678
9101112131415
16171819202122
23242526272829
30
Mon, Nov 10 - Thu, Nov 13
Windows Connections -- Vegas
It's WinConnections time! All sorts of great speeches this time. GP Troubleshooting, My Pre-Con, App-V 101. Will you be there?
www.winconnections.com
Mon, Nov 17 - Tue, Nov 18
Two-Day Intensive Group Policy Essentials Workshop (taught by Jeremy Moskowitz (Lead Instructor) - GPanswers.com / Moskowitz, Inc. )
 Final class of 2008.
This is a Two-Day Intensive Group Policy Essentials Workshop in Atlanta, GA !
Wed, Nov 19 - Thu, Nov 20
Two-Day "Group Policy 2.0" Catch-Up Workshop (taught by Jeremy Moskowitz (Lead Instructor) - GPanswers.com / Moskowitz, Inc. )
 Final class of 2008.
This is a Two-Day "Group Policy 2.0" Catch-Up Workshop in Atlanta, GA !
Fri, Nov 21 - Fri, Nov 21
One-Day Advanced Group Policy Workshop (XP/Vista Focused) (taught by Jeremy Moskowitz (Lead Instructor) - GPanswers.com / Moskowitz, Inc. )
 Final class of 2008.
This is a One-Day Advanced Group Policy Workshop (XP/Vista Focused) in Atlanta, GA !