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!

Windows for business Windows Client for IT Pros Directory services Active Directory
Windows for business Windows Server User experience PowerShell
{count} votes

1 answer

Sort by: Most helpful
  1. Andreas Baumgarten 123.4K Reputation points MVP Volunteer Moderator
    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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.