Solved

AD users and groups reports script/report

Posted on 2015-02-08
2
191 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
Comment Utility
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
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
A procedure for exporting installed hotfix details of remote computers using powershell
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 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 …

762 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

6 Experts available now in Live!

Get 1:1 Help Now