Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Powershell AD query script needed

Posted on 2013-06-20
6
Medium Priority
?
379 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
5 Comments
 
LVL 71

Accepted Solution

by:
Qlemo earned 1500 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 71

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 71

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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Resolving an irritating Remote Desktop connection that stops your saved credentials from being used.
Let's recap what we learned from yesterday's Skyport Systems webinar.
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…

782 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