Merge TFS 2064268: ConstrainedLanguage PowerShell should not block nested cmdlet invocation via runspace (#2159)

* Merge TFS 2064268: Under UMCI PowerShell should not block nested cmdlet invocation via runspace

* Update SessionState.cs

Fixed ExecutionContext property name error.
This commit is contained in:
Paul Higinbotham 2016-09-01 17:21:54 -07:00 committed by Dongbo Wang
parent 1d1c8b770a
commit fe1f035d44
3 changed files with 23 additions and 3 deletions

View file

@ -93,8 +93,6 @@ namespace System.Management.Automation
}
InitialSessionState.SetSessionStateDrive(Context, true);
InitialSessionState.CreateQuestionVariable(Context);
}
/// <summary>

View file

@ -351,6 +351,10 @@ namespace System.Management.Automation
v = new PSUICultureVariable();
this.GlobalScope.SetVariable(v.Name, v, false, true, this, CommandOrigin.Internal, fastPath: true);
// $?
v = new QuestionMarkVariable(this.ExecutionContext);
this.GlobalScope.SetVariableForce(v, this);
// $ShellId - if there is no runspace config, use the default string
string shellId = ExecutionContext.ShellID;
@ -648,4 +652,4 @@ namespace System.Management.Automation
}
#endregion Errors
} // SessionStateInternal class
}
}

View file

@ -629,6 +629,24 @@ namespace System.Management.Automation
return variable;
} // SetVariable
/// <summary>
/// Sets a variable to scope without any checks.
/// This is intended to be used only for global scope.
/// </summary>
/// <param name="variableToSet">PSVariable to set</param>
/// <param name="sessionState">SessionState for variable</param>
/// <returns></returns>
internal void SetVariableForce(PSVariable variableToSet, SessionStateInternal sessionState)
{
if (Parent != null)
{
throw new NotImplementedException("SetVariableForce");
}
variableToSet.SessionState = sessionState;
GetPrivateVariables()[variableToSet.Name] = variableToSet;
}
/// <summary>
/// Sets a variable to the given value.
/// </summary>