#Created By - Abhishek Bansal
<#Read Me !!
1. Script Usage - Useful if members of AD Group are large in number. There are cases where Get-ADGroupMember fails when we have lots of members. ( More then 5K /6K )
2. Script is capable of exporting not only users objects but others too. ( Ex Groups ).
3. User need to input AD Group name when prompt & results can be checked in Groupname_Membership.csv file.
<#Read Me !!
1. Script Usage - Useful if members of AD Group are large in number. There are cases where Get-ADGroupMember fails when we have lots of members. ( More then 5K /6K )
2. Script is capable of exporting not only users objects but others too. ( Ex Groups ).
3. User need to input AD Group name when prompt & results can be checked in Groupname_Membership.csv file.
For using it, just copy the below code, run it
#>
$group = Read-Host "Enter AD Group Name"
$dn = Get-ADGroup -Identity $group -Properties * | Select objectClass -ExpandProperty Member
$line = 0
$linecount = $dn.Count
$percentagecomplete= 0
foreach($row in $dn)
{
$line++
$percentagecomplete = ($line/$linecount)*100
$row = $row.trim()
Write-Progress -Activity "Checking Status.." -PercentComplete $percentagecomplete -Status "$line out of $linecount"
Get-ADObject -Properties * -Filter{DistinguishedName -like $row} | Select Name,Samaccountname,@{n="Member Category";e={$_.ObjectClass}} | Export-Csv ./$group.Membership.csv -NoTypeInformation -Append
}
No comments:
Post a Comment