List_GPOs_and_Links.hta (In the book)

Download file: list_gpos_and_links.hta (4 Kb)

<HTML>
<HEAD>
<!--
Script : List_GPMC_Information.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!
-->
<TITLE>List GPOs and Links</TITLE>
<HTA:APPLICATION ID="List_GPOs_And_Links"
APPLICATIONNAME="List_GPOs_And_Links"
BORDER="dialog"
CAPTION="yes"
CONTEXTMENU="yes"
ICON="graphics/title.ico"
INNERBORDER="yes"
MINIMIZEBUTTON="yes"
MAXIMIZEBUTTON="yes"
SCROLLABLE="yes"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes"
WINDOWSTATE="maximize">
<LINK href='GroupPolicy.css' rel="stylesheet" type="text/css">
<SCRIPT src='GPMgmt.vbs' language="VBScript"></SCRIPT>
<SCRIPT src='HTA_Help.vbs' language="VBScript"></SCRIPT>
</HEAD>
<BODY>
<SCRIPT language="VBScript">
Sub Window_OnLoad
self.resizeTo 600,700
CreateGPMObjects
Dim gpmSitesContainer
Dim gpmSearchCriteria, somSearchCriteria
Dim GPO_List, GPO, GPO_List_HTML
Dim SOM_List, SOM, siteSOM_List

Set gpmSitesContainer = gpm.GetSitesContainer(dnsForestRoot,"","",0)
Set gpmSearchCriteria = gpm.CreateSearchCriteria()
Set somSearchCriteria = gpm.CreateSearchCriteria()
Set GPO_List = gpmDomain.SearchGPOs(gpmSearchCriteria)

GPO_List_Heading.innerHTML = "The following list contains GPOs in the " & gpmDomain.Domain & " domain, the containers linked to them, and their inheritance settings."

For Each GPO In GPO_List
AddHTML GPO_List_HTML, "<hr>"
AddHTML GPO_List_HTML, "<li>GPO Name: " & GPO.DisplayName & "</li>"
Set somSearchCriteria = gpm.CreateSearchCriteria()
somSearchCriteria.Add _
gpmConstants.SearchPropertySOMLinks, gpmConstants.SearchOpContains, GPO
Set SOM_List = gpmDomain.SearchSOMs(somSearchCriteria)
AddHTML GPO_List_HTML, "<ul>"
If SOM_List.Count <> 0 Then
For Each SOM In SOM_List
AddHTML GPO_List_HTML, _
"<li>Link Name: " & SOM.Name & _
"<ul><li>Type: " & ConvertSOMType(SOM.Type) & "</li>" & _
"<li>Inheritance: " & SOM.GPOInheritanceBlocked & "</li></ul></li>"
Next

Set siteSOM_List = gpmSitesContainer.SearchSites(somSearchCriteria)
For Each SOM In siteSOM_List
AddHTML GPO_List_HTML, _
"<li>Name: " & SOM.Name & _
" (Type - " & ConvertSOMType(SOM.Type) & ")" & _
" (Inheritance - " & SOM.GPOInheritanceBlocked & ")</li>"
Next
Else
AddHTML GPO_List_HTML, "<li>No links found to this GPO.</li>"
End If
AddHTML GPO_List_HTML, "</ul>"
Next
GPO_List_Span.innerHTML = GPO_List_HTML
Dim wmiSearchCriteria, wmiFilter_List, wmiFilter
Dim gpoSearchCriteria, Linked_GPO_List, WMIFilter_List_HTML

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

wmiFilterCount_Span.innerHTML = wmiFilter_List.Count
For Each wmiFilter In wmiFilter_List
AddHTML WMIFilter_List_HTML, "<li>" & wmiFilter.Name & " (" & wmiFilter.Description & ")"
Set gpoSearchCriteria = gpm.CreateSearchCriteria()
gpoSearchCriteria.Add _
gpmConstants.SearchPropertyGPOWMIFilter,gpmConstants.SearchOpEquals, wmiFilter
Set Linked_GPO_List = gpmDomain.SearchGPOs(gpoSearchCriteria)
If Linked_GPO_List.Count = 0 Then
AddHTML WMIFilter_List_HTML, "<ul><li>No GPOs are linked to this WMI Filter.</li></ul>"
Else
AddHTML WMIFilter_List_HTML, "<ul>"
For Each GPO In Linked_GPO_List
AddHTML WMIFilter_List_HTML, _
"<li>Linked to GPO " & GPO.DisplayName & "</li>"
Next
AddHTML WMIFilter_List_HTML, "</ul>"
End If
AddHTML WMIFilter_List_HTML, "</ul>"
Next
WMIFilter_List_Span.innerHTML = WMIFilter_List_HTML
End Sub

</SCRIPT>
<div class="Title">List GPOs and Links</div>
<button onclick="window.print()">Print</button>
<p>
<span id="GPO_List_Heading" class="ListHeading">GPO List</span>
<ul><span id="GPO_List_Span"></span></ul><br>
<div class="ListHeading">WMI Filter count:</div> <span id="wmiFilterCount_Span"></span>
<ul><span id="WMIFilter_List_Span"></span></ul><br>
</p>

</BODY>
</HTML>
 

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 !