?
Solved

Powershell Script to Pull all the AD Group in Domain

Posted on 2014-09-29
7
Medium Priority
?
1,386 Views
Last Modified: 2014-09-30
Team, Need help on getting Powershell Script to Pull all the AD Group in Domain. I need the below output in report.

- Groups name with users count in entire domain
- Last modified Date
0
Comment
Question by:Sekar Chinnakannu
[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
  • 3
  • 3
7 Comments
 
LVL 4

Expert Comment

by:ambatihp
ID: 40351529
$GroupArray = Get-ADGroup -Properties * -Filter * -SearchBase "DC=corp,DC=yourcompany,DC=local"
Foreach($G In $GroupArray)
{
    Write-Host $G.Name
    Write-Host "-------------"
    $G.Members
}

Pull all of these into a excel and do a pivot.
0
 
LVL 25

Author Comment

by:Sekar Chinnakannu
ID: 40351544
I am getting all users, computers as output, I am looking for a script to generate all groups in a domain.

- AD Group name with users count in entire domain
- Last modified Date
0
 
LVL 5

Expert Comment

by:Abdul Khadja Alaoudine
ID: 40351648
Below script will give you list of AD groups with memeber count in each group and modifed date for the groups.

$GroupArray = Get-ADGroup -Properties Modified, Members -Filter * -SearchBase "DC=yourcompany,DC=local"
Foreach($Group In $GroupArray)
 {
     Write-Host
     Write-Host "Group Name:"$Group.Name
     Write-Host "Total members:"($Group.Members).count
     Write-Host "Modified date:"$Group.modified
     Write-Host
 }

To get total number of users in domain

$users = Get-ADUser -Filter * -SearchBase "DC=yourcompany,DC=local"
$users.count

To get list of users and their modified date

$UserArray = Get-ADUser -Filter * -SearchBase "DC=yourcompany,DC=local" -Properties Modified
Foreach($User In $UserArray)
 {
     Write-Host
     Write-Host "User Name:"$User.Name
     Write-Host "Modified date:"$User.modified
     Write-Host
 }
0
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
LVL 25

Author Comment

by:Sekar Chinnakannu
ID: 40351711
Also can you please help me to get output in CSV file
0
 
LVL 5

Expert Comment

by:Abdul Khadja Alaoudine
ID: 40351712
Looks like you added 'To get total number of users in domain' line to the script. Remove it, save the ps1 file and try again.
0
 
LVL 25

Author Comment

by:Sekar Chinnakannu
ID: 40351714
Its working fine, can you help me to add OU details for the group and same need to generate as csv file like below format.

Group Name, Users Count, Modified Date, OU
0
 
LVL 5

Accepted Solution

by:
Abdul Khadja Alaoudine earned 2000 total points
ID: 40351825
Here we go...

$GroupArray = Get-ADGroup -Properties Modified, Members -Filter * -SearchBase "DC=yourcompany,DC=local"
$GroupArray | Select Name,@{Name="Users Count";Expression={($_.members).count}},Modified,DistinguishedName | Export-CSV "Groups.csv"
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

Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
Microsoft Office 365 is a subscriptions based service which includes services like Exchange Online and Skype for business Online. These services integrate with Microsoft's online version of Active Directory called Azure Active Directory.
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 to another domain controller. Log onto the new domain controller with a user account t…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Suggested Courses

752 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