Solved

Powershell AD query script needed

Posted on 2013-06-20
6
367 Views
Last Modified: 2013-06-26
Need a powershell script to get these fields and save to csv.

Username
Group membership
Last login
Display name
OU
Enabled/disabled
0
Comment
Question by:cj_cb
  • 3
  • 2
6 Comments
 
LVL 68

Accepted Solution

by:
Qlemo earned 500 total points
ID: 39263246
Since a user can be member of multiple groups, how would you like to have that displayed? Just a comma-separated list?
Are the Quest AD tools an option? They simplify things with pre-W2008R2 domains.
0
 

Author Comment

by:cj_cb
ID: 39263281
yes just a comma-seperated list is good, i will look into Quest but we are 2008r2 active domain.
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 39263349
Then we can use the ActiveDirectory module, and the Get-AD* cmdlets ...
0
 

Author Comment

by:cj_cb
ID: 39263399
that may work, was hoping for a little more detail on how to use the cmdlet.
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 39264432
Sorry, I wasn't finished, but had to leave.
Something like this?
Import-Module ActiveDirectory
Get-ADUser -Filter * -Properties * |
  select Name,
        @{n='Group Membership'; e={($_.MemberOf | % {(get-adgroup $_).Name}) -join ','}},
        LastLogonDate, DisplayName, DistinguishedName, Enabled |
  Export-CSV 'C:\Results.csv'

Open in new window

0

Join & Write a Comment

The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
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 configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

744 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