I'm in need of assistance on finding a powershell command to find all shared mailboxes that have AD Security Groups with 'SendAs' permissions assigned to them; to a text file.
The script I have so far is:
$ExchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http://MY-EXCHANGE BOX/PowerShell/" -Authentication Kerberos
Import-PSSession $ExchangeSession
$WFMGroups = $GroupSAMs = %{Get-Mailbox $_ | select -ExpandProperty dist* | %{Get-ADPermission $_ |
?{$_.extendedrights -like '*Send-As*'} | select -ExpandProperty User | %{$_.tostring().replace("DOMAIN\","")}} |
%{get-adobject -filter{samaccountname -eq $_}} | ?{$_.ObjectClass -eq "group"}} | select -ExpandProperty name
foreach ($WFMGroup in $WFMGroups)
{
$WFMGroup.GroupScope = "Universal"
Set-DistributionGroup -Identity $WFMGroup -Alias $WFMGroup
Set-DistributionGroup -Identity "$WFMGroup" -EmailAddressPolicyEnabled "$false" -DisplayName "$WFMGroup" -PrimarySmtpAddress "$WFMGroup@maildomain.com" -HiddenFromAddressListsEnabled:$true -ManagedBy "AD-OBJECT"
}