Create Group Policy Reports

by Feb 17, 2012

Windows Server 2008 R2 comes with the GroupPolicy PowerShell module. You might have to install that feature first before you can use it – run these lines with full Administrator privileges:

Import-Module ServerManager
Add-WindowsFeature GPMC

Once installed, the GroupPolicy module provides you with a lot of new cmdlets to manage group policy objects. Here’s a function that creates a nice HTML report for one or all group policies available in your domain:

function Show-GPOReport {
  param(
  $GPOName = $null,
  $filename = "$env:temp\report.hta"
  )

  Import-Module GroupPolicy
  if ($GPOName -eq $null) {
    Get-GPO -All | Select-Object -ExpandProperty DisplayName
  } else {
    Get-GPOReport -Name $GPOName -ReportType Html | Out-File $filename
    Invoke-Item $filename
  }
}

Twitter This Tip! ReTweet this Tip!