Powershell command to retrieve Username, first name, lastname and department in Active Directory

Eve Harris 1 Reputation point

Does anyone know what PowerShell command to use to export Username, first name, last name and department from Active Directory? I am still learning, appreciate the help!

Active Directory
Active Directory
A set of directory-based technologies included in Windows Server.
6,058 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,427 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Andreas Baumgarten 99,376 Reputation points MVP

    Hi @Eve Harris ,

    please try Get-ADUser : https://learn.microsoft.com/en-us/powershell/module/activedirectory/get-aduser?view=windowsserver2022-ps

    # Get all AD Users  
    Get-ADUser -Filter * -Properties Department | Select-Object GivenName, SurName, Department  
    # Get user by SamAccountName  
    Get-ADUser -Identity mmouse -Properties Department | Select-Object GivenName, SurName, Department  


    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Andreas Baumgarten

    1 person found this answer helpful.
    0 comments No comments