diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/GetComputerInfoCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/GetComputerInfoCommand.cs index 6914b491e..d43641997 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/GetComputerInfoCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/GetComputerInfoCommand.cs @@ -85,7 +85,6 @@ namespace Microsoft.PowerShell.Commands #region Instance Data private string _machineName = localMachineName; // we might need to have cmdlet work on another machine - private ProgressRecord _progress = null; /// /// Collection of property names from the Property parameter, @@ -225,17 +224,10 @@ namespace Microsoft.PowerShell.Commands /// private void UpdateProgress(string status) { - if (_progress != null) - { - _progress.RecordType = ProgressRecordType.Completed; - WriteProgress(_progress); - } + ProgressRecord progress = new ProgressRecord(0, activity, status ?? ComputerResources.ProgressStatusCompleted); + progress.RecordType = status == null ? ProgressRecordType.Completed : ProgressRecordType.Processing; - if (status != null) - { - _progress = new ProgressRecord(0, activity, status); - WriteProgress(_progress); - } + WriteProgress(progress); } /// diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ComputerInfo.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ComputerInfo.Tests.ps1 index b9b486b2d..ab6f97c56 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ComputerInfo.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ComputerInfo.Tests.ps1 @@ -1010,6 +1010,18 @@ try { $computerInfo = Get-ComputerInfo $computerInfo | Should -BeOfType 'Microsoft.PowerShell.Commands.ComputerInfo' } + + It "Verify progress records in Get-ComputerInfo" { + try { + $j = Start-Job { Get-ComputerInfo } + $j | Wait-Job + $j.ChildJobs[0].Progress | Should -HaveCount 9 + $j.ChildJobs[0].Progress[-1].RecordType | Should -Be ([System.Management.Automation.ProgressRecordType]::Completed) + } + finally { + $j | Remove-Job + } + } } Describe "Tests for Get-ComputerInfo" -tags "Feature", "RequireAdminOnWindows" {