Solved

AD users and groups reports script/report

Posted on 2015-02-08
2
195 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
2 Comments
 
LVL 4

Accepted Solution

by:
Praveen Kumar Bonala earned 250 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 250 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
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 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 …

839 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