Solved

query group disabled AD group members

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

Join & Write a Comment

In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
This article will help you understand what HashTables are and how to use them in PowerShell.
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…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

759 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

18 Experts available now in Live!

Get 1:1 Help Now