-
-
Save ykfq/2b19d9b44ccfed98925dc779b9266c20 to your computer and use it in GitHub Desktop.
This file contains 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
$filter = "(proxyAddresses=SMTP:[email protected])" | |
$gcs = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().GlobalCatalogs | |
$gcs | % { | |
$searcher = $_.GetDirectorySearcher() | |
$searcher.Filter = $filter | |
$results = $searcher.FindAll() | |
if ($results.Count -gt 0) | |
{ | |
$results | |
} | |
else | |
{ | |
"Not found on GC: " + $_.Name | |
} | |
} | |
$domains = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().Domains | |
$domains | % { | |
$dcs = $_.DomainControllers | |
$dcs | % { | |
$searcher = $_.GetDirectorySearcher() | |
$searcher.Filter = $filter | |
$results = $searcher.FindAll() | |
if ($results.Count -gt 0) | |
{ | |
$results | |
} | |
else | |
{ | |
"Not found on DC: " + $_.Name | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment