Created
February 10, 2016 20:53
-
-
Save bill-long/3da8b8db69857c5379dc 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