Script runs fine in PS, running from C# gives execution of scripts disabled, system set to unrestricted


my system set executionpolicy level of unrestricted.  i running powershell script wrote on machine.  it runs fine powershell , commandline via powershell myscript.ps1

when run c# app compile exe run scripts fails, missing running scripts c#?  i built/compiled exe on 32 bit machine , running on 64 bit 2008 server.  i have ps v2 on both machines.
public bool runpowershellscript()          {              string validpowershellscript = getproperlyformatedscriptname(_powershellscripttorun);              using (runspace myrunspace = runspacefactory.createrunspace())              {                  pipeline pipe = myrunspace.createpipeline(validpowershellscript);                  myrunspace.open();                  pipe.invoke();                    return true;              }          }

i need more development determine how execution policy works (runspace versus host versus mini-shell), keep in mind you're using 32-bit exe on 64-bit system.  have made sure have set *both* 32-bit , 64-bit instances of powershell same execution policy?


Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Indexing Server

Schannel Issue

oclist /xml or /?