Exchange PowerShell script error No provisioning handler is installed.

Microsoft Exchange 2016

I have a script run under a normal domain user through scheduled tasks to find distribution groups that match a certain criteria and set them to allow external senders. The user has a role with the Distribution Group entry permissions (which includes Get & Set-DistributionGroup). I've tested this user via the EAC and it can see the groups I want and change the RequireSenderAuthenticationEnabled attribute.

From PowerShell as the user typing the commands individually or as the user using the script, the Set-DistributionGroup cmdlet throws an error. I can load the snap-in, run the Get for the results I want but cannot run the set. I understand that giving the user Org Management and/or Admin rights will work around this, but to do so defeats the purpose of the roles and gives the user *far* more access than is needed.

Set-DistributionGroup : No provisioning handler is installed.
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.

Are you using windows powershell or Exhange management Shell you run this command? Did you tried with Exchange Management Shell? if not then try with EMS and share the results
DaveQuanceAuthor Commented:
It needs to be able to run as a scheduled task so I'm not aware of any way to run it through anything other than standard PowerShell.exe. It *does* load the SnapIn for Exchange through it (from my understanding that's how the EMS works, it's just PowerShell pre-loading the SnapIn for you). Post it loading the SnapIn it *does* properly use Get-DistributionGroup.
Hello Dave,

It is fairly easy to load the Exchange Management Shell when executing a scheduled task.
You can find a detailed description and explanation here for example:

The question is:
If you launch the Set-Mailbox command with your user account from a properly loaded exchange management shell, does that work?

Hope this will help

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
DaveQuanceAuthor Commented:

Sorry for the delay.

If you launch the Set-Mailbox command with your user account from a properly loaded exchange management shell, does that work?
Using "Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn" when the user is logged in interactively it always worked fine. Where it fails is when being run as a scheduled task or being run as a different user from an interactive session (basically interactive session fully logged in = good and my other tests all failed).

Now your suggestion to use the same load method on the shortcut provided by the EMS run as a different user *did* give the ability to run set commands. But running that as an invoke at the top of the script doesn't give the shell options to commands below it. At this point the script is no longer required and I looked further only for the benefits of trying to figure it out. At this point with current workloads my academic pursuit of the solution isn't high on the agenda. However, your insight I think would lead to a solution and I'll add my thoughts here in case someone else tries to figure it out:

Potential thoughts I had:
1. Simply take the contacts of the script used in the EMS and add to the bottom, I'm assuming that would work.
2. Research if PowerShell offers a way to invoke the script but take the benefits of what it loads in the script that invoked it.
DaveQuanceAuthor Commented:
Although I did not bring the issue to complete closure, I think zivko's direction was likely the key that would have.
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.