feat: Add script to backup group members via csv file

This commit is contained in:
Björn Benouarets
2025-08-13 08:55:00 +02:00
parent 4b0244468f
commit aeb46eae2d

View File

@@ -0,0 +1,18 @@
$global_catalog = Get-ADDomainController -Discover -Service GlobalCatalog
$server = "$($global_catalog.Name):3268"
$group = ""
$csv_file = "$($group) ($(Get-Date -Format 'yyyy-MM-dd_HH-mm-ss')).csv"
try {
$ad_group = Get-ADGroup -Filter 'Name -eq $group -and GroupScope -eq "DomainLocal" -and GroupCategory -eq "Security"' -Server $server -Properties Member -ErrorAction Stop
$group_members = $ad_group.Member
$group_members | Export-Csv -Path $csv_file -NoTypeInformation
} catch {
Write-Error "Group $group not found"
exit 1
}