I have developed a service that simply watches for a file to be created, then executes a powershell script in an Exchange 2010 environment.
I have tried using a runspace, but find that in order to add the needed snap-in, I must use VS2012 (which I don't have in my lab) so that it will run the 64-bit version of powershell. I've also found a few other hiccups with this approach, seeming that it's difficult to troubleshoot where it breaks down in the script (which works fine outside of the visual studio project). I've also read that Exchange 2010 has to launch a remote session, because local snap-ins are no longer supported? (Found at http://stackoverflow.com/questions/7811754/powershell-snapin-issues-in-c-sharp
I'm now attempting just to launch a process in visual studio - using powershell.exe as the filename and supplying the script name and its parameters, but apparently that's causing issues too. It seems that at least one of my parameters, enclosed in single quotes, is causing a problem.
Is there anyone familiar enough with running powershell scripts through visual studio that can help me get this working?