Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Using Scripts to Manage Group Policy

Updated: March 28, 2003

Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1, Windows Server 2003 with SP2

GPMC provides a comprehensive set of COM interfaces that you can use to script many of the operations supported by the snap-in. To help you get started, the GPMC installation includes sample scripts that use these interfaces. The sample scripts are installed in the \Program Files\GPMC\Scripts\ folder. Full details about the scripting interfaces are documented in the Group Policy Management Console SDK, is installed as Gpmc.chm in Program Files\GPMC\Scripts\ on any computer where you have installed GPMC. The GPMC SDK is also located in the Platform SDK. For more information about scripting GPMC operations, see the Windows Security Collection of the Windows Server 2003 Technical Reference (or see the Windows Security Collection on the Web at http://www.microsoft.com/reskit).

The sample scripts form the basis for a scripting toolkit that you can use to solve specific administrative problems. For example, you can run queries to find all GPOs in a domain that have duplicate names, or to generate a list of all GPOs in a domain whose settings are disabled or partially disabled. The scripts also illustrate some key scripting objects and methods to provide an overview of the many administrative tasks that you can accomplish with the Group Policy Management snap-in. You can modify and distribute the sample scripts in accordance with the terms of the End User License Agreement.

All of the scripts run from the command line. Running a script with the /? switch displays the usage for that script.

The sample scripts echo output to the command window and must be executed by using Cscript.exe. If Cscript.exe is not your default scripting host, you will need to explicitly specify Cscript.exe on the command line. For example, type d: \Program Files\GPMC\Scripts>cscript ListAllGPOs.wsf.

To make Cscript the default scripting host, type cscript //h:cscript at the command line.

Many of the sample scripts rely on a library of common helper functions contained in the file Lib_CommonGPMCFunctions.js. If you copy these scripts to another location, you must also copy this library file to that location in order for the script samples to work.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.