List_GPO_Permissions.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 GPO Permissions</TITLE>
  <HTA:APPLICATION ID="List_GPO_Permissions" 
    APPLICATIONNAME="List_GPO_Permissions" 
    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">
Dim gpm, gpmConstants, gpmDomain

Sub Window_OnLoad
self.resizeTo 600,500
CreateGPMObjects

End Sub

Sub ViewPermissions
Dim Results_HTML
Set gpmSearchCriteria = gpm.CreateSearchCriteria()
gpmSearchCriteria.Add gpmConstants.SearchPropertyGPODisplayName, gpmConstants.SearchOPcontains, GPOName.value
Set gpmGPO_List = gpmDomain.SearchGPOs(gpmSearchCriteria)
On Error Resume Next
Set gpmGPO = gpmDomain.GetGPO(gpmGPO_List.item(1).ID)
If Err.Number <> 0 Then
    MsgBox "Sorry, that GPO name could not be found.  Please try again."
    Exit Sub
End If
AddHTML Results_HTML, "Here's information about the selected GPO:<br>"
AddHTML Results_HTML, String(30,"=") & "<br>"
AddHTML Results_HTML, "GPO Friendly Name: " & gpmGPO.DisplayName & "<br>"
AddHTML Results_HTML, "Domain: " & gpmGPO.DomainName & "<br>"
AddHTML Results_HTML, "GPO GUID: " & gpmGPO.ID & "<br>"
AddHTML Results_HTML, "Modification Timestamp: " & gpmGPO.ModificationTime & "<br>"
AddHTML Results_HTML, "<br>"

Set gpmSecurityInfo = gpmGPO.GetSecurityInfo()
AddHTML Results_HTML, "The GPO has " & gpmSecurityInfo.Count & " security entries on the ACL.<br>"

For i=1 To gpmSecurityInfo.Count
    AddHTML Results_HTML, String(40,"=") & "<br>"
    Set gpmPermission = gpmSecurityInfo.item(i)
    
    With gpmPermission.trustee
        AddHTML Results_HTML, "Trustee Name: " & .trusteeName & "<br>"
        AddHTML Results_HTML, "Trustee Type: " & ConvertTrusteeType(.trusteeType) & "<br>"
        AddHTML Results_HTML, "Trustee Domain: " & .trusteeDomain & "<br>"
        AddHTML Results_HTML, "Trustee DS Path: " & .trusteeDSPath & "<br>"
        AddHTML Results_HTML, "Trustee SID: " & .trusteeSid & "<br>"
    End With
    
    With gpmPermission
        AddHTML Results_HTML, "ACE Mask: " & ConvertAccessSetting(.permission) & "<br>"
        AddHTML Results_HTML, "Denied? " & .denied & "<br>"
        AddHTML Results_HTML, "Inheritable? " & .inheritable & "<br>"
        AddHTML Results_HTML, "Inherited? " & .inherited & "<br>"
    End With
 
Next

AddHTML Results_HTML, "Completed processing the security entries for " & gpmGPO.DisplayName & "."
Results_Span.innerHTML = Results_HTML
End Sub

</SCRIPT>
<div>List GPO Permissions</div>
<button onclick="window.print()">Print</button>
<p>
<div>Select a GPO to View</div>
<table>
	<tr>
		<td>GPO Name:</td>
		<td><input type="text" size="30" id="GPOName"></td>
	</tr>
	<tr>
		<td> </td>
		<td>
			<button id="ViewPermissions" onClick="ViewPermissions()">View Permissions</button>
		</td>
	</tr>
</table>
<ul>
<span id="Results_Span"></span>
</ul>
</p>

</BODY>
</HTML>