feat: Add script to backup group members via csv file
This commit is contained in:
@@ -11,12 +11,16 @@ try {
|
|||||||
$ad_group = Get-ADGroup -Filter 'Name -eq $group -and GroupScope -eq "DomainLocal" -and GroupCategory -eq "Security"' -Server $server -Properties Member -ErrorAction Stop
|
$ad_group = Get-ADGroup -Filter 'Name -eq $group -and GroupScope -eq "DomainLocal" -and GroupCategory -eq "Security"' -Server $server -Properties Member -ErrorAction Stop
|
||||||
$csv_export_table = @()
|
$csv_export_table = @()
|
||||||
$ad_group.Member | ForEach-Object {
|
$ad_group.Member | ForEach-Object {
|
||||||
$ad_user = Get-ADUser -Identity $_ -Properties * -Server $server
|
try {
|
||||||
|
$ad_user = Get-ADUser -Identity $_ -Properties * -Server $server -ErrorAction Stop
|
||||||
$csv_export_table += [PSCustomObject]@{
|
$csv_export_table += [PSCustomObject]@{
|
||||||
Group = $group
|
Group = $group
|
||||||
MemberEmail = $ad_user.SamAccountName
|
MemberEmail = $ad_user.SamAccountName
|
||||||
MemberDistinguishedName = $ad_user.DistinguishedName
|
MemberDistinguishedName = $ad_user.DistinguishedName
|
||||||
}
|
}
|
||||||
|
} catch {
|
||||||
|
Write-Error "User $group not found and skipped..."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
|
Reference in New Issue
Block a user