Share via


View Active Directory USN changes with powershell

ipmo activedirectory #import active directory module<br>
$dc = "dc1.contoso.com" #domain controller<br>
$usn = (([directoryServices.ActiveDirectory.Domain]::GetCurrentDomain()).DomainControllers | ?{$_.name -like $dc}).highestcommittedusn #get the current usn<br>
#you will need to store the usn in a state file or put a sleep here<br>
get-adobject -Filter {uSNChanged -ge $usn} -pr uSNChanged -Server $dc | Get-ADReplicationAttributeMetadata -filter {LocalChangeUsn -ge $usn} -Server $dc | fl Object,LastOriginatingChangeTime,AttributeName,AttributeValue