Solved

query group disabled AD group members

Posted on 2014-11-05
1
115 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
Always backup Domain, SYSVOL etc.using processes according to Microsoft Best Practices. This is meant as a disaster recovery process for small environments that did not implement backup processes and did not run a secondary domain controller that ne…
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.
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

688 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