diff --git a/src/System.Management.Automation/engine/GetCommandCommand.cs b/src/System.Management.Automation/engine/GetCommandCommand.cs index 53c0827e12b..88048e96216 100644 --- a/src/System.Management.Automation/engine/GetCommandCommand.cs +++ b/src/System.Management.Automation/engine/GetCommandCommand.cs @@ -390,6 +390,8 @@ protected override void BeginProcessing() /// protected override void ProcessRecord() { + _commandsWritten.Clear(); + // Module and FullyQualifiedModule should not be specified at the same time. // Throw out terminating error if this is the case. if (_isModuleSpecified && _isFullyQualifiedModuleSpecified) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Command.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Command.Tests.ps1 index 2a34c3aad7e..e4fff519b05 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Command.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Get-Command.Tests.ps1 @@ -263,4 +263,10 @@ Describe "Get-Command Tests" -Tags "CI" { VerifyDynamicParametersExist -cmdlet $results[0] -parameterNames $paramName VerifyParameterType -cmdlet $results[0] -parameterName $paramName -ParameterType System.Text.Encoding } + + It "Piping more than one CommandInfo works" { + $result = Get-Command -Name Add-Content, Get-Content | Get-Command + $result.Count | Should -Be 2 + $result.Name | Should -Be "Add-Content","Get-Content" + } }