Get-AdUser -Server: how do you include all domains?

Welcome Forums General PowerShell Q&A Get-AdUser -Server: how do you include all domains?

This topic contains 2 replies, has 2 voices, and was last updated by

Ben
 
Participant
6 months, 1 week ago.

  • Author
    Posts
  • #101598
    Ben

    Participant
    Points: 1
    Rank: Member

    Hi all,

    I'm trying to build a command from Get-AdUser in Powershell to include all the domains my enterprise has to query a user for different things. I tried the below but it didn't work. Can someone suggest a right way to do this, if possible?

    Get-ADUser [username] -Server "domain1", "domain2" -Properties * | select name, password*
    
  • #101604

    Participant
    Points: 307
    Helping Hand
    Rank: Contributor

    You can use the Windows Server ADAC to write this code for you which you can later tweak as needed.
    You'd use the ADAC GUI, to navigate the actions you'd like, open the ADAC PowerShell History viewer to see the script code.

    Simply, it's something like...

    'domain1', 'domain2'| %{Get-ADUser -Filter * -Server $_ | Select Name,password*}
    
    # or 
    
    $EnterpriseDomains = "domain1", "domain2"
    $EnterpriseDomains | %{Get-ADUser -Filter * -Server $_ | Select Name}
    
    • #101607
      Ben

      Participant
      Points: 1
      Rank: Member

      Thank you! Looking at this all now

The topic ‘Get-AdUser -Server: how do you include all domains?’ is closed to new replies.