Powershell group export
I needed to get a list of people in som AD group for an audit so I wrote a quick script to export each group matching my filter to a CSV-file and populate it with name and samaccountname. Setting semi colon as an delimiter ensures that you can open the CSV-file in Excel with no additional work to get columns correct.
1
2
3
4
5
6
7
8
$groups = Get-ADGroup -filter { name -like "Company-Fileserver-ACL*" }
foreach ($group in $groups)
{
Write-Output $group.name
$file=$group.name + ".csv"
Get-ADGroupMember $group.name | Select-Object name, samaccountname | Export-Csv -path $file -NoTypeInformation -delimiter ";"
}
This post is licensed under CC BY 4.0 by the author.