Powershell Set-MailboxJunkEmailConfiguration issues


Really trying hard to get into Powershell, but way too often hitting the wall! (I will be in bed by now if I was using the GUI) anyway...

I am trying to add an email to the sender blacklist. After logging in successfully to the Exchange (365), I run the following command to add the email address I wish to block:

Get-Mailbox | Set-MailboxJunkEmailConfiguration -BlockedSendersAndDomains "spam@me.com"

I then get the following error:
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.

How can I make this work?
I thought that powershell could do anything, so why logging in to the GUI?
I have also logged in to the Outlook Web App many times before & only using 1 user

Thank you
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AmitIT ArchitectCommented:
You first need to sign-in to PS console. Follow this

Then use this KB:


Basically, you need to create a session with your user id. When you are login remotely to PS session. That is same on On-premises also.
defreyAuthor Commented:
hi Amit,

I have no issues connecting to the console.

the error shows up after running the following command (as explained here https://support.microsoft.com/en-us/kb/2545137 & follow instructions step by step)

Get-Mailbox | Set-MailboxJunkEmailConfiguration -BlockedSendersAndDomains "spam@me.com"

I get the following error
"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."

How can I enter the command without having any errors?

defreyAuthor Commented:
any ideas, anyone?
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

Guy LidbetterCommented:
hi Defrey,

That command looks correct to me. Nothing wrong there... (Other than if you have any current entries... they will all be replaced. Updating with new entries is a bit different)

I can only imagine that you more than likely have a mailbox which has not yet been logged into and as such cannot be updated. The command might be breaking with the error.

Try adding "-ErrorAction SilentlyContinue" to the end and see what happens.


defreyAuthor Commented:
still no luck!
I even deleted the shared mailbox just in case.
I only got one user in the entire 365, logged in to the OWA countless time & still the same error
Guy LidbetterCommented:
OK, Basic question, but we should cover all bases...
Are you assigned to the required roles?
Organization Management
Records Management
Recipient Management
Help Desk

Are you able to run a Get-MailboxJunkEmailConfiguration -identity MailboxName?
defreyAuthor Commented:
Hi Guy,

Yes I am able to run this command & get a result

defreyAuthor Commented:
Please see screenshot error after running

Get-Mailbox | Set-MailboxJunkEmailConfiguration -BlockedSendersAndDomains "spam@me.com"

Guy LidbetterCommented:
Hi Defrey,

Apologies been offline for a bit.

Can you please try creating a new user from scratch, send an email to the account and then log into OWA with the account, then run the above commands against the mailbox specifying the indentity?

Everything you are posting shows to be correct, why you are still getting the error is odd.
If you have a) logged in with the account and b) sent and received some mail into the account in question, you should be all good.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
defreyAuthor Commented:
i cannot so it from scratch as I only have 1 subscription...
Guy LidbetterCommented:
And everything else works fine?
defreyAuthor Commented:
everything is perfect
Just learning the powershell......the hard way
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.