Solved

query group disabled AD group members

Posted on 2014-11-05
1
111 Views
Last Modified: 2014-11-20
Hi,

I have been using this script to display list of users in a specified group:

param
(  
    [Parameter(Mandatory=$true,position=0)]
    [String]$GroupName
)

Import-Module activedirectory

Get-ADGroupMember $GroupName -Recursive | Get-ADUser -Properties * | Select sAMAccountName,givenName,SN | Export-csv "C:\ed\ps_script\list group member\w7localadm.csv" -nti

What should I add if I need to display the "Department" field of the user as well as whether or not the account is disabled in AD?

Please advise.
0
Comment
Question by:nav2567
1 Comment
 
LVL 39

Accepted Solution

by:
footech earned 500 total points
ID: 40424394
You just need to modify the following portion.
Get-ADGroupMember $GroupName -Recursive | Get-ADUser -Properties * | Select sAMAccountName,givenName,SN,Department,Enabled | Export-csv "C:\ed\ps_script\list group member\w7localadm.csv" -nti 

Open in new window


However, some advice for optimization - it's best not to use -Properties * outside of testing.  Instead you should list what properties you are interested in retrieving (besides the default set).
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Find out how to use Active Directory data for email signature management in Microsoft Exchange and Office 365.
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now