PowerShell Commanlet set-mailboxjunkemailconfiguration "all users" -TrustedSendersAndDomains @{add="contorso.com"}

Is there a way to add bulk AD accounts to this commandlet? I can foresee the potential problems with this depending on how your AD Organization units are grouped. But couldn't find much online in my brief search.
Do I just apply the FQDN instead of individual users?

set-mailboxjunkemailconfiguration "all users"  -TrustedSendersAndDomains @{add="contorso.com"}

Thanks for your help.
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.

Will SzymkowskiSenior Solution ArchitectCommented:
The below should work for all users..
$Domains = "contoso.com"
$users = get-mailbox -ResultSize "unlimited"

ForEach ($user in $users) { 

$SetDomain = Get-MailboxJunkEmailConfiguration -Identity $user
$SetDomain.TrustedSendersAndDomains += $Domains
Set-MailboxJunkEmailConfiguration -Identity $user -TrustedSendersAndDomains $SetDomain.TrustedSendersAndDomains 


Open in new window

Thats it.


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
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Bad style, Will. If a commandlet has advanced features like the ADD syntax we should use it.
get-mailbox -ResultSize "unlimited" | % {
  Set-MailboxJunkEmailConfiguration -Identity $_ -TrustedSendersAndDomains @{add="contorso.com"}

Open in new window

Will SzymkowskiSenior Solution ArchitectCommented:
:-P either way will work. But I get you.

Cloud as a Security Delivery Platform for MSSPs

Every Managed Security Service Provider (MSSP) needs a platform to deliver effective and efficient security-as-a-service to their customers. Scale, elasticity and profitability are a few of the many features that a Cloud platform offers. View our on-demand webinar to learn more!

bflanneryAuthor Commented:
Thanks Will -  We had some outside help that committed to this. But I know this will be utilized again soon, looking forward to testing this out.
Thanks Everyone.
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Again, this is bad style for many reasons. One more: Get-Mailbox should always be used in a pipe, not as shown above.
Will SzymkowskiSenior Solution ArchitectCommented:
@Qlemo - I do get you regarding the Form of how to write scripts, however there are SEVERAL ways to accomplish this. I think it is good to note different ways to accomplish this, but ultimately the script works and gets the results the user is looking for, which is the most important part of EE.

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.