Solved

Powershell AD query script needed

Posted on 2013-06-20
6
369 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

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
edit user account 1 31
How to set up a screen saver as a announcement page- When no users are logged into the network PCs. 4 52
Windows 10 and WSUS 3.2 5 48
MDM vs GPO 16 37
New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
A safe way to clean winsxs folder from your windows server 2008 R2 editions
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 Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

863 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

20 Experts available now in Live!

Get 1:1 Help Now