Skip to content

Commit ef64321

Browse files
SteveL-MSFTadityapatwardhan
authored andcommitted
Fix piping more than one CommandInfo to Get-Command (PowerShell#10929)
1 parent 3768be1 commit ef64321

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/System.Management.Automation/engine/GetCommandCommand.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,8 @@ protected override void BeginProcessing()
390390
/// </summary>
391391
protected override void ProcessRecord()
392392
{
393+
_commandsWritten.Clear();
394+
393395
// Module and FullyQualifiedModule should not be specified at the same time.
394396
// Throw out terminating error if this is the case.
395397
if (_isModuleSpecified && _isFullyQualifiedModuleSpecified)

test/powershell/Modules/Microsoft.PowerShell.Core/Get-Command.Tests.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,4 +263,10 @@ Describe "Get-Command Tests" -Tags "CI" {
263263
VerifyDynamicParametersExist -cmdlet $results[0] -parameterNames $paramName
264264
VerifyParameterType -cmdlet $results[0] -parameterName $paramName -ParameterType System.Text.Encoding
265265
}
266+
267+
It "Piping more than one CommandInfo works" {
268+
$result = Get-Command -Name Add-Content, Get-Content | Get-Command
269+
$result.Count | Should -Be 2
270+
$result.Name | Should -Be "Add-Content","Get-Content"
271+
}
266272
}

0 commit comments

Comments
 (0)