Exchange – remove address from all groups and hide it from GAL

Filename:  script.ps1

$email = (read-host “email”)

$GG = Get-DistributionGroup
$RG = $GG  | where {(Get-DistributionGroupMember $_ | foreach {$_.PrimarySmtpAddress}) -contains “$email”}

foreach( $dg in $RG ){
Remove-DistributionGroupMember $dg -Member $email
}

get-mailbox -Identity $email | Set-Mailbox -HiddenFromAddressListsEnabled $true

 

This entry was posted in Exchange. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *