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.

Error:
Set-DistributionGroup : No provisioning handler is installed.
DaveQuanceAsked:
Who is Participating?
 
zivkoCommented:
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:
https://www.interfacett.com/blogs/how-to-run-the-exchange-management-shell-ems-in-powershell/

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
0
 
Gaurav SinghSolution ArchitectCommented:
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
0
 
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.
0
 
DaveQuanceAuthor Commented:
zivko,

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.
0
 
DaveQuanceAuthor Commented:
Although I did not bring the issue to complete closure, I think zivko's direction was likely the key that would have.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.