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

Important
  • 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.
  • You must also 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.
To import the Group Policy Module
  1. Open Windows PowerShell. To open Windows PowerShell, point to All Programs, point to Accessories, point to Windows PowerShell, and then click Windows PowerShell V2.

  2. At the Windows PowerShell prompt, type Import-Module GroupPolicy –verbose

    Important

    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

Additional considerations

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 https://go.microsoft.com/fwlink/?LinkId=131389. This reference is a downloadable spreadsheet.

Additional references

  • Group Policy Management Console

  • For the Windows PowerShell Technology Center see https://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 https://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 https://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 https://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.


Table Of Contents