Thursday, September 29, 2016

Creating GPO Report Using PowerShell

Hi folks,

Just wanted to share with you about a nice method for creating HTML reports for more than one server by using PowerShell. In pre-Windows 2012 environment there was a nice command gpresult /h filename.htm. One drawback of it that it is local.

I recently needed to generate GPO report on multiple Exchange server. This is where the Get-GPResultantSetOfPolicy cmdlet came to help. You can read about this cmdlet here.

The below command ran Get-GPResultantSetOfPolicy against all Exchange servers that were piped by using Get-ExchangeServer command and for each of them generates a report that contains server name:

Get-ExchangeServer EXCH* |foreach {Get-GPResultantSetOfPolicy -computer $_.Name -reporttype html -path D:\InfoSec\Reports\$_.Name.html}

I hope you will find it useful.

Enjoy!