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

This topic contains 2 replies, has 2 voices, and was last updated by  Ben 3 weeks ago.

  • Author
    Posts
  • #101598

    Ben
    Participant

    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

    postanote
    Participant

    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

      Thank you! Looking at this all now

You must be logged in to reply to this topic.