-
-
Save ykfq/48f7bdbb9ab5c7fe139ba722562d28bb to your computer and use it in GitHub Desktop.
Check every GC and DC for a specific objectGUID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$guid = "bc87047d-25e8-11d3-9079-00805f31f826" | |
$gcs = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().GlobalCatalogs | |
$gcs | % { | |
$entry = [ADSI]("GC://" + $_.Name + "/<GUID=" + $guid + ">") | |
if ($entry.Guid -ne $null) | |
{ | |
$entry | |
} | |
else | |
{ | |
"Not found on GC: " + $_.Name | |
} | |
} | |
$domains = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().Domains | |
$domains | % { | |
$dcs = $_.DomainControllers | |
$dcs | % { | |
$entry = [ADSI]("LDAP://" + $_.Name + "/<GUID=" + $guid + ">") | |
if ($entry.Guid -ne $null) | |
{ | |
$entry | |
} | |
else | |
{ | |
"Not found on DC: " + $_.Name | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment