Author Posts

February 26, 2018 at 9:48 am

How is it possible to search on multiple domains in Get-ADUser Query?
I have 3 domains – Domain1.com, Domain2.com, Domain3.com

ForEach-Object{
		Get-ADUser -Identity $_.samaccountname -Properties *
	}|

February 26, 2018 at 11:03 am

Are the domains in the same Forrest ? If so you could probably do something like this :-

$Domains = (Get-ADForest).domains

ForEach ($Domain in $Domains) {

$UserAccount= Get-ADUser -server $domain |
select SamAccountName

$Users += $UserAccount
}

$Users| Export-CSV Users.csv -notypeinformation

February 26, 2018 at 1:03 pm

Unfortunately they aren't in the same forest.

February 26, 2018 at 2:33 pm

Map a PSDrive to each domain using the AD provider. Change to each drive in turn and run your query.