Author Posts

September 30, 2014 at 5:35 am


Beginner question...
I'm trying to do this:

$junked = Get-MailboxJunkEmailConfiguration $user |select BlockedSendersAndDomains -ExpandProperty BlockedSendersAndDomains



I want to remove the "" from that variable so I can overwrite de junk rule doin' something like this:

Set-MailboxJunkEmailConfiguration $user -BlockedSendersAndDomains $junked

The first command gives me an error saying that the collection has fixed size...

September 30, 2014 at 5:48 am

This worked for me:

$junked = Get-MailboxJunkEmailConfiguration $user
$junked.BlockedSendersAndDomains -= ""
Set-MailboxJunkEmailConfiguration -Identity $user -BlockedSendersAndDomains $junked.BlockedSendersAndDomains

September 30, 2014 at 6:01 am

Ondrej Zilinec,

Thanks for replying.

But if there is more than one "" 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 -= ""
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 -= ""
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (op_Subtraction:String) [], Ru
    + FullyQualifiedErrorId : MethodNotFound

September 30, 2014 at 6:25 am

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 '*'}
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:

[i]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.[/i]

September 30, 2014 at 7:58 am

Mike F Robbins,

Great! Worked perfectly.