Skip to content

Instantly share code, notes, and snippets.

@HarmJ0y
Created Sep 5, 2017
Embed
What would you like to do?
OU_edit_metadata.ps1
# 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