# encoding: ascii
# api: powershell
# title: GPO replication status
# description: GPO replication status across Domain Controller.
# version: 0.1
# author: Manuel TOUSSAINT
# license: CC0
# x-poshcode-id: 4810
# x-archived: 2014-01-21T08:56:16
# x-published: 2014-01-17T15:49:00
#
# To run on a DC with ActiveDirectory and GroupPolicy Module imported in the session.
#
#Created by toussman@gmail.com on 17/01/2014 
#http://theplatformadmin.blogspot.co.uk/

param(
  [parameter(Mandatory = $True )][String]$GPOName
 )

$DCList = (get-addomaincontroller -filter *).hostname 

$colGPOVer = @()

foreach ($DC in $DCList){

 $objGPOVers = New-Object System.Object

 $GPOObj = Get-GPO $GPOName -server $DC

 $UserVersion = [string]$GPOObj.User.DSVersion + ' (AD), ' + [string]$GPOObj.User.SysvolVersion + ' (sysvol)'
 $ComputerVersion = [string]$GPOObj.Computer.DSVersion + ' (AD), ' + [string]$GPOObj.Computer.SysvolVersion + ' (sysvol)'

 $objGPOVers | Add-Member -type noteproperty -name GPOName -value $GPOName
 $objGPOVers | Add-Member -type noteproperty -name DCName -value $DC
 $objGPOVers | Add-Member -type noteproperty -name UserVersion -value $UserVersion
 $objGPOVers | Add-Member -type noteproperty -name ComputerVersion -value $ComputerVersion

 $colGPOVer += $objGPOVers 
}

$colGPOVer | sort-object GPOName, DCName
