Share via

Powershell command to check user's block or allow settings?

Anonymous
2018-07-17T15:42:39+00:00

In OWA, under Settings > Mail > Accounts > Block or allow, there are two options, "Don't move email to my Junk Email folder" or "Automatically filter junk email" as shown in the screenshot.

From this article, https://blogs.msdn.microsoft.com/tzink/2017/12/14/making-sure-your-junk-email-filtering-is-enabled-in-office-365/, I came up with the powershell command below to view this setting for individual users but how would I output a list of this setting for all users?

Get-MailboxJunkEmailConfiguration -Identity "user@example.com" | fl Enabled
Microsoft 365 and Office | Subscription, account, billing | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2018-07-18T09:35:03+00:00

Hi Saleaway,

Thank you for contacting Microsoft Forum Support. From my test in the lab, I found the error is probably caused by the same Display Name, alias or prefix of proxy email address of different mailboxes in your organization. For example, if you have a user mailbox named “Vincent”, while a shared mailbox also named “Vincent”, PowerShell will confuse  which one you want to check. For this issue, I suggest you run the following command. Also the reference link is here.

Get-Mailbox -RecipientTypeDetails UserMailbox -OrganizationalUnit "<Domain name /Area>" | Get-MailboxJunkEmailConfiguration | Format-Table -Auto Identity,Enabled

(Sample: Get-Mailbox -RecipientTypeDetails UserMailbox -OrganizationalUnit "contoso.com/North America" | Get-MailboxJunkEmailConfiguration | Format-Table -Auto Identity,Enabled)

The OrganizationUnit parameter locates the physical position in Active Directory. And if you don’t familiar with it, you can run the following command to get the organization unit values. You can refer to this article for more details. As a side note, if there is no value indicating the area value, you can just ignore it.

Get-OrganizationalUnit

And if you have any further question in the process above, feel free to let me know. I’ll help you further.

Regards,

Marvin

Was this answer helpful?

4 people found this answer helpful.
0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Anonymous
    2018-07-18T14:48:50+00:00

    Regarding the first command, I've checked and can't find any duplicates so not sure why it's not working.

    Get-MailboxJunkEmailConfiguration -Identity * -ResultSize unlimited | Where {$_.Enabled -eq $false}

    The command you posted worked.  I found my OU with the Get-OrganizationalUnit command but wasn't sure if it was the right value at first because it was very long. Example

    Get-Mailbox -RecipientTypeDetails UserMailbox -OrganizationalUnit "NAMasdf123456.prod.outlook.com/Microsoft Exchange Hosted Organizations/mydomain.onmicrosoft.com" | Get-MailboxJunkEmailConfiguration | Format-Table -Auto Identity,Enabled

    This command also worked:

    $AllUsers = Get-Mailbox -ResultSize unlimited -RecipientTypeDetails UserMailbox; $AllUsers | foreach {Get-MailboxJunkEmailConfiguration -Identity $_.Identity} | Where {$_.Enabled -eq $false} | Format-Table -Auto Identity,Enabled

    Was this answer helpful?

    2 people found this answer helpful.
    0 comments No comments
  2. Anonymous
    2018-07-19T12:53:11+00:00

    Hi Saleaway,

    We're glad to hear the PowerShell commands are workable on this issue. What's more, it's highly appreciated for your sharing. Have a excellent day!

    Regards,

    Marvin

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2018-07-17T19:00:16+00:00

    Found an example here but it doesn't work.  https://docs.microsoft.com/en-us/powershell/module/exchange/antispam-antimalware/get-mailboxjunkemailconfiguration?view=exchange-ps

    PS C:\WINDOWS\system32> Get-MailboxJunkEmailConfiguration -Identity * -ResultSize unlimited | Where {$_.Enabled -eq $false}

    Returns an error:

    Multiple mailbox users match identity "*". Specify a unique value.

    Was this answer helpful?

    0 comments No comments