Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

AD users and groups reports script/report

Posted on 2015-02-08
2
Medium Priority
?
206 Views
Last Modified: 2015-02-25
I need some basic script to list details about all users in a domain and all groups in a domain

for users I just need basic stuff like username, last logon date, password last set, account status (i.e. enabled/disabled/expired)

for groups I just need stuff like group name and all members (to also include nested groups)

I want them written to a CSV, so all users in 1 report, and all groups in another...
0
Comment
Question by:pma111
[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
2 Comments
 
LVL 4

Accepted Solution

by:
Praveen Kumar Bonala earned 1000 total points
ID: 40597167
Following script for exporting users to CSV:

Import-Module ActiveDirectory

 Get-ADUser -filter * -properties employeeType,EmployeeID,GivenName,Surname,CN,Title,Manager,Department,Country,City,EmailAddress,LastLogonDate,Created -SearchBase "DC=domainname,DC=com" | select employeeType,EmployeeID,GivenName,Surname,CN,Title,Manager,Department,Country,City,EmailAddress,LastLogonDate,Created | ConvertTo-Csv | Out-File c:\output.csv

Following link gives more information regarding this

https://4sysops.com/archives/export-active-directory-users-with-powershell/


Following PS Script for export group info to csv

Add-PSSnapin Quest.ActiveRoles.ADManagement
$csv = Get-Content "f:\Temp\group.csv"

$result = $csv | foreach-object {
$group=$_
get-qadgroupmember "$_" -sizelimit 0 -indirect | select-object samaccountname,@{n="GroupName";e={$group}}
}
$result | export-csv f:\temp\groupandmem.csv -notypeinformation
0
 
LVL 53

Assisted Solution

by:Will Szymkowski
Will Szymkowski earned 1000 total points
ID: 40597415
This is pretty strightforward, no need for such a long script...

Active Directory User Stats
import-module activedirectory
get-aduser -filter * -properties Name, sAMAccountName, lastlogondate, passwordlastset, Enabled | select Name, sAMAccountName, lastlogondate, passwordlastset, Enabled | export-csv "c:\userstatus.csv"

Open in new window


Group Stats
$Groups = get-adgroup -filter *
foreach ($Group in $Groups) {
Get-ADGroupMember -Identity $Group | select $group, name | out-file "c:\groupmembers.csv" -append
}

Open in new window


Will.
0

Featured Post

Industry Leaders: 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

After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
How to deal with a specific error when using the Enable-RemoteMailbox cmdlet to create a mailbox in the cloud-based service, for an existing user in an on-premises Active Directory.
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 …
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 …
Suggested Courses

636 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