I’ve not blogged for quite a while. Let’s come back with a small PowerShell script for retrieving Active Directory Group Members.
The bellow scripts retrieve all the Active Directory groups in a specific OU and count the number of members.
Import-Module ActiveDirectory
$groups = Get-ADGroup -searchbase "OU=MyOU,DC=myDC,DC=net" -filter *
$myArray = @()
foreach($g in $groups)
{
$members = Get-ADGroupMember($g)
$myObject = New-Object System.Object
$myObject | Add-Member -type NoteProperty -name Name -Value $g.Name
$myObject | Add-Member -type NoteProperty -name Count -Value $members.Length
$myArray += $myObject
}
$myArray
No comments:
Post a Comment