List_GPOs_and_Links.hta (In the book)

Jan
25
2013

 

<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>List GPOs and Links</div>
<button onclick="window.print()">Print</button>
<p>
<span id="GPO_List_Heading">GPO List</span>
<ul><span id="GPO_List_Span"></span></ul><br>
<div>WMI Filter count:</div> <span id="wmiFilterCount_Span"></span>
<ul><span id="WMIFilter_List_Span"></span></ul><br>
</p>

</BODY>
</HTML>
Copyright © GPanswers.com. All rights reserved. GPanswers.com is a service of PolicyPak Software