Multiple domain search

This topic contains 3 replies, has 3 voices, and was last updated by  Don Jones 2 months, 4 weeks ago.

  • Author
    Posts
  • #94633

    Thomas
    Participant

    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 *
    	}|
    
  • #94639

    Simon B
    Participant

    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

    • #94642

      Thomas
      Participant

      Unfortunately they aren't in the same forest.

  • #94647

    Don Jones
    Keymaster

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

You must be logged in to reply to this topic.