[ Team LiB ] |
Recipe 9.2 Creating a GPO9.2.1 ProblemYou want to create a GPO to force users to have a particular desktop configuration or provision configuration settings on workstations or servers. 9.2.2 Solution9.2.2.1 Using a graphical user interface
9.2.2.2 Using a command-line interface> creategpo.wsf <GPOName> [/domain:<DomainDNSName>] 9.2.2.3 Using VBScript' This code creates an empty GPO. ' ------ SCRIPT CONFIGURATION ------ strGPO = "<GPOName>" ' e.g. Sales GPO strDomain = "<DomainDNSName>" ' e.g. rallencorp.com ' ------ END CONFIGURATION --------- set objGPM = CreateObject("GPMgmt.GPM") set objGPMConstants = objGPM.GetConstants( ) ' Initialize the Domain object set objGPMDomain = objGPM.GetDomain(strDomain, "", objGPMConstants.UseAnyDC) ' Create the GPO and print the results set objGPO = objGPMDomain.CreateGPO( ) WScript.Echo "Successfully created GPO" objGPO.DisplayName = strGPO WScript.Echo "Set GPO name to " & strGPO 9.2.3 DiscussionWhen you create a GPO through the GPMC, it is initially empty with no settings or links configured. See Recipe 9.6 for more on modifying GPO settings, and Recipe 9.12 for creating a link. 9.2.3.1 Using VBScriptTo create a GPO, I first instantiate a GPMDomain object for the domain to add the GPO to. This is accomplished with the GPM.GetDomain method. Then it is just a matter of calling the GPMDomain.CreateGPO method (with no parameters) to create an empty GPO. A GPM.GPO object is returned from this method, which I then use to set the display name of the GPO. 9.2.4 See AlsoMS KB 216359 (HOW TO: Identify Group Policy Objects in the Active Directory and SYSVOL) and MSDN: GPMDomain.CreateGPO |
[ Team LiB ] |