public static void SetExecutionPolicy(this Runspace runspace, ExecutionPolicy policy, ExecutionPolicyScope scope) { string command = string.Format(CultureInfo.InvariantCulture, "Set-ExecutionPolicy {0} -Scope {1} -Force", policy.ToString(), scope.ToString()); runspace.Invoke(command, null, false); }
public void SetExecutionPolicy(ExecutionPolicy policy, ExecutionPolicyScope scope) { string command = string.Format(CultureInfo.InvariantCulture, "Set-ExecutionPolicy {0} -Scope {1} -Force", policy.ToString(), scope.ToString()); Invoke(command, inputs: null, outputResults: false); }