locked
how to get list of active users with the details like samaccountname, name, department, job tittle, email in active directoy 2008 R2/ RRS feed

  • Question

  • how to get list of active users with the details like samaccountname, name, department, job tittle, email in active directoy 2008 R2/

    Friday, April 13, 2012 1:35 PM

Answers

  • Get-ADUser -Filter {enabled -eq "True"} -SearchBase "OU=Users,DC=contoso,DC=com" | Select-Object Name,sAMAccountName,Department,Title,EmailAddress

    You just need to change the search base part to match your OU structure
    • Marked as answer by Gautam Ji Friday, April 13, 2012 8:14 PM
    Friday, April 13, 2012 6:22 PM
  • Thanks............

    I got the answer as below .......


    dsquery * -filter "(&(objectCategory=person)(objectClass=user)(!objectClass=user)(!userAccountControl:1.2.840.113556.1.4.803:=2))" -attr sAMAccountName name title department mail -limit 0 > users.txt

    • Marked as answer by Gautam Ji Friday, April 13, 2012 8:14 PM
    Friday, April 13, 2012 8:14 PM

All replies

  • Try Get-ADUser

    Get-Help Get-ADUser

    Karl


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer



    My Blog: http://unlockpowershell.wordpress.com
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join ("6B61726C6D69747363686B65406D742E6E6574"-split"(?<=\G.{2})",19|%{[char][int]"0x$_"})

    • Proposed as answer by Bigteddy Friday, April 13, 2012 2:23 PM
    Friday, April 13, 2012 1:46 PM
  • While I'm at it, see the top post in this forum: "How to ask a question efficiently in TechNet forum"

    Karl


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer



    My Blog: http://unlockpowershell.wordpress.com
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join ("6B61726C6D69747363686B65406D742E6E6574"-split"(?<=\G.{2})",19|%{[char][int]"0x$_"})

    Friday, April 13, 2012 1:47 PM
  • Get-ADUser -Filter {enabled -eq "True"} -SearchBase "OU=Users,DC=contoso,DC=com" | Select-Object Name,sAMAccountName,Department,Title,EmailAddress

    You just need to change the search base part to match your OU structure
    • Marked as answer by Gautam Ji Friday, April 13, 2012 8:14 PM
    Friday, April 13, 2012 6:22 PM
  • HI......... I need to search whole orgnization no ou part.........

    Friday, April 13, 2012 6:45 PM
  • Take the entire -SearchBase -SearchBase "OU=Users,DC=contoso,DC=com" out and it will search the entire domain. I just put that in there cause usually user accounts are in either one, or certain OU's
    Friday, April 13, 2012 7:00 PM
  • Thanks............

    I got the answer as below .......


    dsquery * -filter "(&(objectCategory=person)(objectClass=user)(!objectClass=user)(!userAccountControl:1.2.840.113556.1.4.803:=2))" -attr sAMAccountName name title department mail -limit 0 > users.txt

    • Marked as answer by Gautam Ji Friday, April 13, 2012 8:14 PM
    Friday, April 13, 2012 8:14 PM