Windows PowerShell is a Windows command-line shell and scripting language that you can use to automate many of the same tasks that you perform in the user interface by using the Group Policy Management Console (GPMC). To help you perform these tasks, Group Policy provides more than 25 cmdlets. Each cmdlet is a simple, single-function command-line tool.
You can use the Group Policy cmdlets to perform the following tasks for domain-based Group Policy objects (GPOs):
-
Maintaining GPOs: GPO creation, removal, backup, and import.
-
Associating GPOs with Active Directory® containers: Group Policy link creation, update, and removal.
-
Setting inheritance flags and permissions on Active Directory organizational units (OUs) and domains.
-
Configuring registry-based policy settings and Group Policy Preferences Registry settings: Update, retrieval, and removal.
-
Creating and editing Starter GPOs.
To use the Windows PowerShell Group Policy cmdlets, you must be running either Windows Server 2008 R2 on a domain controller or on a member server that has the GPMC installed, or Windows 7 with Remote Server Administration Tools (RSAT) installed. RSAT includes the GPMC and its cmdlets.
You must also use the Import-Module grouppolicy command to import the Group Policy module before you use the cmdlets at the beginning of every script that uses them and at the beginning of every Windows PowerShell session.
You can use the GPRegistryValue cmdlets to change registry-based policy settings and the GPPrefRegistryValue cmdlets to change registry preference items. For information about the registry keys that are associated with registry-based policy settings, see the Group Policy Settings Reference. This reference is a downloadable spreadsheet.