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 * }|
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 * }|
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
Unfortunately they aren’t in the same forest.
Map a PSDrive to each domain using the AD provider. Change to each drive in turn and run your query.