<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>Create and Link New GPO</TITLE> <HTA:APPLICATION ID="Create and Link New GPO" APPLICATIONNAME="Create and Link New GPO" 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 Sub Window_OnLoad self.resizeTo 600,400 CreateGPMObjects ouName.Value = adsiDomain End Sub Sub CreateLink Dim Results_HTML Set OU_To_Link = GetOU(OUName.Value) If OU_To_Link Is Nothing Then MsgBox OUName.Value & " was not found.", vbExclamation, "OU Not Found!" Exit Sub End If Set NewGPO = gpmDomain.CreateGPO() NewGPO.DisplayName = GPOName.Value AddHTML Results_HTML, "<p>A GPO with the friendly name '" & NewGPO.DisplayName & "' has been created." With NewGPO AddHTML Results_HTML, "<ul>" AddHTML Results_HTML, "<li>GUID: " & .ID AddHTML Results_HTML, "<li>ADSI path: " & .Path AddHTML Results_HTML, "</ul>" End With AddHTML Results_HTML, "<br>" Set SOM = gpmDomain.GetSOM(OU_To_Link.distinguishedName) If TopLink.Checked Then GPOPrecedence = 1 Else GPOPrecedence = -1 End If AddHTML Results_HTML, "<p>Linking the GPO " & NewGPO.DisplayName & " to an " & ConvertSOMType(SOM.Type) & " container called " & SOM.Name & "." On Error Resume Next Set SOM_Link = SOM.CreateGPOLink(GPOPrecedence, NewGPO) If Err.Number = 0 Then AddHTML Results_HTML, "<p>Successfully linked " & NewGPO.DisplayName & " To " & SOM.Name & "." MsgBox "Successfully linked " & NewGPO.DisplayName & " To " & SOM.Name & "." Else AddHTML Results_HTML, "<p>An error occurred while linking to OU:" & Err.Description & "(Error:" & Err.Number & ")" MsgBox "An error occurred while linking to OU:" & Err.Description & "(Error:" & Err.Number & ")" End If Results_Span.innerHTML = Results_HTML End Sub </SCRIPT> <p><div>Create and Link New GPO</div></p> <p> <div>Enter OU and GPO information.</div> <table> <tr> <td>OU Name:</td> <td><input type="text" size="50" id="OUName"></td> </tr> <tr> <td>GPO Name:</td> <td><input type="text" size="30" id="GPOName"></td> </tr> <tr> <td> </td> <td><input type="checkbox" id="TopLink">Assign GPO Link to top of precedence list.</input></td> </tr> <tr> <td> </td> <td> <button id="CreateLink" onClick="CreateLink()">Create Link</button> </td> </tr> </table> <ul> <span id="Results_Span"></span> </ul> </p> </BODY> </HTML>