Skip to content

Commit

Permalink
Execution Policy Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Burns committed Nov 30, 2015
1 parent 06c8a4d commit d266676
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/LaunchPad/Services/JobServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,16 @@ public void LaunchScriptWithParams(string name, PowerShellParam psParam)
[AutomaticRetry(Attempts = 0)]
public void Run(string name)
{
// Executionpolicy Bypass - Thanks to @ducke
//
InitialSessionState initial = InitialSessionState.CreateDefault();

// Replace PSAuthorizationManager with a null manager
// which ignores execution policy
initial.AuthorizationManager = new AuthorizationManager("Microsoft.PowerShell");

//Create Runspace
var runspace = RunspaceFactory.CreateRunspace();
var runspace = RunspaceFactory.CreateRunspace(initial);
runspace.Open();

//Create Pipeline
Expand All @@ -98,8 +106,16 @@ public void Run(string name)
[AutomaticRetry(Attempts = 0)]
public void Run(string name, Dictionary<string, string> psParams)
{
// Executionpolicy Bypass - Thanks to @ducke
//
InitialSessionState initial = InitialSessionState.CreateDefault();

// Replace PSAuthorizationManager with a null manager
// which ignores execution policy
initial.AuthorizationManager = new AuthorizationManager("Microsoft.PowerShell");

//Create Runspace
Runspace runspace = RunspaceFactory.CreateRunspace();
var runspace = RunspaceFactory.CreateRunspace(initial);
runspace.Open();

//Create Pipeline
Expand Down

0 comments on commit d266676

Please sign in to comment.