Created
September 24, 2018 18:10
-
-
Save sytone/a281d622727465ff83e8f4332e176c34 to your computer and use it in GitHub Desktop.
Get user in AD from all domains in the forest
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
param ( | |
$Filter | |
) | |
$arrayOfFQDNs = ([System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest() | select domains).Domains | select Name | % { $_.Name } | |
foreach ($FQDN in $arrayOfFQDNs) { | |
$adUser = get-aduser -Filter $Filter -properties * -server $FQDN -ErrorAction SilentlyContinue | |
if ($adUser -ne $null) { | |
break | |
} | |
} | |
$adUser |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment