I am trying to add a UI to some automation that runs PowerShell Scripts.
I am able to get this working when I am running in Visual Studio. But when I deploy it, it apparently quits the Using block after on the PowerShellInstance.AddScript(script); line. Then ofcourse, it doesn't run the powershell script. Why do you think it
might be doing this when deployed only and not having any issues on running it from VS? Here is the snippet that I have issues with:
try
{
using (PowerShell PowerShellInstance = PowerShell.Create())
{
string script = "Set-ExecutionPolicy -Scope Process -ExecutionPolicy Unrestricted; Get-ExecutionPolicy";
PowerShellInstance.AddScript(script);
PowerShellInstance.Invoke();
}
}
---------------------
Thanks!
Thanks very much, Manoj Deshpande.