Active Directory

Powershell Script to Get List of Active Users with the Details like samaccountname, name, department, job tittle, email in Active Directory

 

In this blog will see how to list active users with details like samaccountname, name, department, job tittle, email, etc., in Active Directory using powershell script.

  

A dsquery solution:

dsquery * -Filter "(&(objectCategory=person)(objectClass=user))" -Attr givenName sn displayName sAMAccountName mail proxyAddresses distinguishedName > AllUsers.txt

 

A PowerShell solution using the AD module cmdlet:

Get-ADUser -Filter * -Properties givenName, sn, displayName, sAMAccountName, mail, proxyAddresses, distinguishedName | ft givenName, sn, displayName, sAMAccountName, mail, proxyAddresses, distinguishedName > .\AllUsers.txt

 

Script for logon name, First name and Last name for all Active Directory users in a specified OU. 

$params = @{  "Filter" = "*"  "SearchBase" = "OU=Users,DC=fabrikam,DC=com"}Get-ADUser @params |  Select-Object Surname,GivenName,SamAccountName |  Export-Csv "MyOutputFile.csv" –NoTypeInformation

 

36 thoughts on “Powershell Script to Get List of Active Users with the Details like samaccountname, name, department, job tittle, email in Active Directory

  1. Terrific post however , I was wondering if you could write a litte more on this subject? I’d be very grateful if you could elaborate a little bit more. Thank you!

  2. Thank you for sharing your info. I truly appreciate your
    efforts and I am waiting for your further write ups thanks once again.

  3. Good day! I simply would like to offer you a big thumbs up for your excellent info you have
    right here on this post.

  4. I’m impreѕsed, I have to admit. Seldom dο I encounter a blog
    that’s both equally educative and engaging, and let me tell you, you’ve һit the naіl on the head.

  5. I’ve read a few excellent stuff here. Definitely worth bookmarking for revisiting.
    I wonder how much effort you set to create this type of wonderful informative site.

  6. Hi there i am kavin, its my first time to commenting anyplace,
    when i read this piece of writing i thought i could also create comment due to
    this sensible article.

Leave a Reply

Your email address will not be published. Required fields are marked *