Skip to content

Instantly share code, notes, and snippets.

Created Sep 5, 2017
What would you like to do?
# specify the GPO we're enumerating
$OUName = "TestOU1_policy"
# enumerate the last time the GPO was changed, based on the replication metadata of the 'versionNumber' property
$LastGPOChange = ([datetime](Get-DomainObjectAttributeHistory $OUName -Properties versionNumber | Select-Object -ExpandProperty LastOriginatingChange)).ToUniversalTime()
# grab the SYSVOL path for this particular GPO
$Path = Get-DomainObject $OUName | Select-Object -ExpandProperty gpcfilesyspath
# enumerate all files in the GPO edited +/- 20 seconds from the 'versionNumber' modification time
Get-ChildItem $Path -Recurse -Exclude 'GPT.ini' | ? {
($_.LastWriteTimeUtc -gt $LastGPOChange.AddSeconds(-20)) -and ($_.LastWriteTimeUtc -lt $LastGPOChange.AddSeconds(20))
} | Sort-Object -Property LastWriteTime -Descending
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment