mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix incorrect position of a parameter which resulted in the args passed as input instead of as args (#4963)
This commit is contained in:
@@ -686,7 +686,7 @@ namespace System.Management.Automation
|
||||
/// <exception cref="FlowControlException"></exception>
|
||||
public Collection<PSObject> InvokeScript(string script, params object[] args)
|
||||
{
|
||||
return InvokeScript(script, true, PipelineResultTypes.None, args);
|
||||
return InvokeScript(script, true, PipelineResultTypes.None, null, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -712,7 +712,12 @@ namespace System.Management.Automation
|
||||
try
|
||||
{
|
||||
_context.EngineSessionState = sessionState.Internal;
|
||||
return InvokeScript(scriptBlock, false, PipelineResultTypes.None, null, args);
|
||||
return InvokeScript(
|
||||
sb:scriptBlock,
|
||||
useNewScope:false,
|
||||
writeToPipeline:PipelineResultTypes.None,
|
||||
input:null,
|
||||
args:args);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -13,4 +13,11 @@ Describe 'Basic engine APIs' -Tags "CI" {
|
||||
$result[0].PSSnapIn.Name | Should Be "Microsoft.WSMan.Management"
|
||||
}
|
||||
}
|
||||
|
||||
Context 'executioncontext' {
|
||||
It 'args are passed correctly' {
|
||||
$result = $ExecutionContext.SessionState.InvokeCommand.InvokeScript('"`$args:($args); `$input:($input)"', 1, 2, 3)
|
||||
$result | Should BeExactly '$args:(1 2 3); $input:()'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user