Hi,
Beginner question…
I’m trying to do this:
$junked = Get-MailboxJunkEmailConfiguration $user |select BlockedSendersAndDomains -ExpandProperty BlockedSendersAndDomains
So:
$junked
user@ymail.com
user1@gmail.com
user2@organization.com.br
yahoo@yahoo.com
I want to remove the “user2@organization.com.br” from that variable so I can overwrite de junk rule doin’ something like this:
$junked.Remove("*organization.com.br")
Set-MailboxJunkEmailConfiguration $user -BlockedSendersAndDomains $junked
The first command gives me an error saying that the collection has fixed size…
This worked for me:
$junked = Get-MailboxJunkEmailConfiguration $user
$junked.BlockedSendersAndDomains -= "user2@organization.com.br"
Set-MailboxJunkEmailConfiguration -Identity $user -BlockedSendersAndDomains $junked.BlockedSendersAndDomains
Ondrej Zilinec,
Thanks for replying.
Nice!
But if there is more than one “@organization.com.br” record?
I wanted to get rid of all records from a specific domain.
Also, for me it isn’t working =/
PS C:\Office 365> $junked.BlockedSendersAndDomains -= "user2@organization.com.br"
Falha na invocação do método porque [System.Collections.ArrayList] não contém
um método denominado 'op_Subtraction'.
No linha:1 caractere:1
+ $junked.BlockedSendersAndDomains -= "user2@organization.com.br"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (op_Subtraction:String) [], Ru
ntimeException
+ FullyQualifiedErrorId : MethodNotFound
Give this a shot:
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
$user = 'username'
$junked = Get-MailboxJunkEmailConfiguration -Identity $user | Select-Object -ExpandProperty BlockedSendersAndDomains
$junked = $junked | Where-Object {$_ -notlike '*organization.com.br'}
Set-MailboxJunkEmailConfiguration -Identity $user -BlockedSendersAndDomains $junked
One thing to note is that the user must have logged into their email at least once or you’ll receive the following error message when trying to set their junk email configuration:
Set-MailboxJunkEmailConfiguration : The Junk Email configuration couldn’t be set. The user needs to sign in to Outlook Web App before they can modify their Safe Senders and Recipients or Blocked Senders lists.