Skip to content

Instantly share code, notes, and snippets.

@bill-long
Created February 10, 2016 20:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bill-long/3da8b8db69857c5379dc to your computer and use it in GitHub Desktop.
Save bill-long/3da8b8db69857c5379dc to your computer and use it in GitHub Desktop.
Check every GC and DC for a specific objectGUID
$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