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

Eve Harris 1 Reputation point
2022-10-25T17:42:55.467+00:00

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,244 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,462 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Andreas Baumgarten 104K Reputation points MVP
    2022-10-25T18:03:31.433+00:00

    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)

    Regards
    Andreas Baumgarten

    1 person found this answer helpful.
    0 comments No comments