# Define the path to your CSV file
$csvFilePath = "C:\temp\del-mem.csv"
# Import the CSV file
$membersToRemove = Import-Csv -Path $csvFilePath
# Iterate through each entry in the CSV
foreach ($entry in $membersToRemove) {
$dlName = $entry.DLName
$memberEmail = $entry.MemberEmail
# Remove the member from the distribution group
try {
Remove-DistributionGroupMember -Identity $dlName -Member $memberEmail -Confirm:$false
Write-Host "Removed $($memberEmail) from $($dlName)."
}
catch {
Write-Warning "Failed to remove $($memberEmail) from $($dlName): $($_.Exception.Message)"
}
}
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article