Solved

query group disabled AD group members

Posted on 2014-11-05
1
113 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 40

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Utilizing an array to gracefully append to a list of EmailAddresses
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
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 video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

838 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