Skip to content

Instantly share code, notes, and snippets.

@ykfq
Forked from bill-long/CheckAllDCsForGuid.ps1
Created August 9, 2016 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ykfq/48f7bdbb9ab5c7fe139ba722562d28bb to your computer and use it in GitHub Desktop.
Save ykfq/48f7bdbb9ab5c7fe139ba722562d28bb 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