Category Archives: Group Policy

Episode 5 – BackupRestoreImport-GPO

Download the MP3 Podcast

In this episode we look at how you can Backup, Restore, and Import Group Policy Objects using Windows PowerShell and the cmdlets that come with the Group Policy module in the latest version of RSAT and the GPMC.

$dir = '\\server1\gpobackups'

# Backups
Get-GPO -All |Backup-GPO -Path $dir
Get-GPO remoting |Backup-GPO -Path $dir

#Restore
Restore-GPO -Path $dir -All
Restore-GPO -Path $dir -Name remoting

# Restore a GPO from a specific backup
$id = '00003D27-F9E6-4C59-BF69-938E5AE43D05'
Restore-GPO -Path $dir -BackupId $id

# Create a new GPO named remoting2
Import-GPO -Path $dir -BackupGpoName remoting -TargetName remoting2 -CreateIfNeeded

Brought to you by The Windows PowerShell Bible 2.0 and PowerShellGroup.Org

Episode 4 – Get-GPResultantSetOfPolicy

Download the MP3 Podcast

In this episode we look at how you can generate an RSOP with Windows PowerShell by using Get-GPResultantSetOfPolicy by using the GroupPolicy module that comes with the GPMC that is bundled in Windows Server 2008 R2 and the most recent version of RSAT.

# Populate dir with the current dir regardless of whether
# you are in a script or executing in the shell
if ($MyInvocation.MyCommand.Path) {
    $dir = $MyInvocation.MyCommand.Path
}
else {
    $dir = $pwd
}

$user = 'home\Administrator'
$report = Join-Path $dir 'rsop.html'
$comp = 'Server1'
Get-GPResultantSetOfPolicy -User $user -Path $report -ReportType HTML -Computer $comp

Brought to you by The Windows PowerShell Bible 2.0 and PowerShellGroup.Org

Episode 3 – Get-GPOReport

Download the MP3 Podcast

In this episode we see how we can use Get-GPOReport to retrieve an HTML or XML representation of the settings and configuration of a GPO.

Import-Module grouppolicy
$report='c:\gporeports\remoting.html'
Get-GPO Remoting |Get-GPOReport -ReportType HTML -Path $report
start $report #open in a browser

The below screenshot shows you what is returned in the GPMC. It is not the output of the script. The script opens a similar report in a web browser:

Addendum/Erata: Get-GPOReport shows you more than just what is in the settings tab in the GPMC.  It also provides you the information that can be found in the other tabs when looking at a GPO in the GPMC.

Brought to you by The Windows PowerShell Bible 2.0 and PowerShellGroup.Org

Episode 2 – Get-GPO

Download the MP3 Podcast

In this episode we begin our exploration of the Group Policy module with Get-GPO

PS C:\Users\Administrator.HOME> import-module GroupPolicy
PS C:\Users\Administrator.HOME> Get-GPO Remoting

DisplayName      : Remoting
DomainName       : home.toenuff.com
Owner            : HOME\Domain Admins
Id               : 096431fe-7ae7-4f92-8ed2-48268df5d1b1
GpoStatus        : AllSettingsEnabled
Description      : GPO that will enable remoting
CreationTime     : 5/15/2011 8:28:22 AM
ModificationTime : 5/15/2011 8:28:24 AM
UserVersion      : AD Version: 0, SysVol Version: 0
ComputerVersion  : AD Version: 4, SysVol Version: 4
WmiFilter        :

Brought to you by The Windows PowerShell 2.0 Bible and PowerShellGroup.Org