Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions 9 src/System.Management.Automation/engine/MshCmdlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ public Collection<PSObject> InvokeScript(string script)
/// <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>
Expand All @@ -712,7 +712,12 @@ public Collection<PSObject> InvokeScript(
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
{
Expand Down
7 changes: 7 additions & 0 deletions 7 test/powershell/engine/Api/BasicEngine.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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:()'
}
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.