Tuesday, 7 July 2020

Multiple Group Member Extract through PowerShell

Multiple Group Member Extract through PowerShell


CSV File Format












$groups = Get-Content C:\grouplist.txt

$results = foreach ($group in $groups) {
    Get-ADGroupMember $group | select  samaccountname, name, @{n='GroupName';e={$group}}, @{n='Description';e={(Get-ADGroup $group -Properties description).description}}
}

$results

$results | Export-csv C:\grouplistresult.txt -NoTypeInformation



No comments:

Post a Comment