SharePoint Workflow Activities 2010 - Execute Powershell script

Sep 6, 2012 at 8:27 PM

I am currently running into a problem when I try to execute a powershell script in a workflow which calls Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin - I receive an error stating Set-Mailbox is not recognized as a name of a cmdlet.  I have installed exchange management tools on our sharepoint 2010 dev server.  I can execute the same script from the sharepoint 2010 dev server and I am able to execute a poweshell script from the workflow which doesn't call a powershell snap-in.  Any help on this issue will be greatly appreciated.  Thanks

Nov 19, 2012 at 6:36 PM

Did you ever find a solution to this one? I'm facing a similar issue with EWS and i'm thinking that whatever solution you ended up with may be a good clue for me.

All the best,

Steve

Dec 13, 2012 at 2:48 PM

Did either of you find a solution to this issue? I am experiencing the same thing. Any help would be greatly appreciated.

Feb 26, 2013 at 7:05 PM
The only solution I could come up with was to execute a powershell script from the workflow to extract information to a text file and then in the next step I executed a powershell script that would run a scheduled task that would kick off my completed powershell script on the sharepoint server to work with exchange.
May 1, 2013 at 2:14 PM
Please try the following:
  1. Ensure all your PSSnapin modules are loaded into GAC (using gacutil)
  2. Edit PowerShell profile (notepad $profile.allusersallhosts) to load SnapIn by default. Add the "Add-PSSnapin Microsoft.Exchange ..... " . Save.