Group Policy in Windows Server® 2008 R2 provides support for Windows PowerShell, a Windows command-line shell and scripting language. You can use the Windows PowerShell Group Policy cmdlets to automate many of the same tasks for domain-based Group Policy objects (GPOs) that you perform in the user interface by using the Group Policy Management Console (GPMC).
Tasks that you can perform
- Maintaining GPOs: GPO creation, removal, backup, and import
- Associating Group Policy objects (GPOs) with Active Directory® directory service containers: Group Policy link creation, update, and removal
- Setting permissions on GPOs
- Modifying inheritance flags on Active Directory organizational units (OUs) and domains
- Configuring registry-based policy settings and Group Policy Preferences Registry settings: Update, retrieval, and removal
- Creating Starter GPOs
To help you complete these tasks, more than 20 Group Policy cmdlets are provided in Windows Server 2008 R2. Each cmdlet is a simple, single-function command-line tool. By using combinations of cmdlets, you can automate more complex tasks. You can also combine actions with scheduled tasks to ensure that specific Group Policy management tasks occur when you want them to. For example, you can back up a GPO, output the result to a file, and then append the file every time that you perform a backup. This creates a report for every scheduled backup.
Using the cmdlets for Group Policy
|To import the Group Policy Module|
Open Windows PowerShell. To open Windows PowerShell, point to All Programs, point to Accessories, point to Windows PowerShell, and then click Windows PowerShell V2.
At the Windows PowerShell prompt, type Import-Module GroupPolicy –verbose
You must perform these steps when you open a Windows PowerShell session and you want to use the Group Policy cmdlets.
|To view a list of Group Policy cmdlets|
At the Windows PowerShell prompt, type Get-Command *GP* -commandtype cmdlet
|To view Help for the Group Policy cmdlets|
At the Windows PowerShell prompt, do the following:
To display basic Help, type Get-Help <cmdlet_name>
To display detailed Help, type Get-Help <cmdlet_name> -detailed
To display technical Help, type Get-Help <cmdlet_name> -full
- To display basic Help, type Get-Help <cmdlet_name>
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
Group Policy Management Console
For the Windows PowerShell Technology Center see
http://go.microsoft.com/fwlink/?LinkID=102372, This Web site is an entry point for PowerShell documentation, such as information about deployment, operations, training, support, and communities.
For the Windows PowerShell blog see
http://go.microsoft.com/fwlink/?LinkID=128557: This Web site is an entry point for Windows PowerShell blogs that includes information about current Windows PowerShell developments, best practices, training, and other resources.
For the Group Policy Technology Center see
http://go.microsoft.com/fwlink/?LinkID=116313. This Web site is an entry point for Group Policy documentation, such as information about deployment, operations, training, support, and communities.
For the Group Policy Settings Reference see
http://go.microsoft.com/fwlink/?LinkId=131389. This document lists Group Policy settings described in administrative template (ADMX) files and security settings. This spreadsheet includes all administrative template policy settings for Windows Server 2008 R2 and Windows 7.