From 8a3e02dcf7155aa9fce671a02073ccb9630639a0 Mon Sep 17 00:00:00 2001 From: krishnayalavarthi Date: Mon, 12 Apr 2021 14:16:31 -0700 Subject: [PATCH] `get-counter` issue with `-computer` parameter (#15166) * get-counter issue fixed * Update src/Microsoft.PowerShell.Commands.Diagnostics/GetCounterCommand.cs Co-authored-by: Krishna Yalavarthi Co-authored-by: Travis Plunk --- .../GetCounterCommand.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Diagnostics/GetCounterCommand.cs b/src/Microsoft.PowerShell.Commands.Diagnostics/GetCounterCommand.cs index 4a6941cc13..f04c8ceff0 100644 --- a/src/Microsoft.PowerShell.Commands.Diagnostics/GetCounterCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Diagnostics/GetCounterCommand.cs @@ -587,13 +587,14 @@ namespace Microsoft.PowerShell.Commands { foreach (string machine in ComputerName) { + string slashBeforePath = path.Length > 0 && path[0] == '\\' ? string.Empty : "\\"; if (machine.StartsWith("\\\\", StringComparison.OrdinalIgnoreCase)) { - retColl.Add(machine + "\\" + path); + retColl.Add(machine + slashBeforePath + path); } else { - retColl.Add("\\\\" + machine + "\\" + path); + retColl.Add("\\\\" + machine + slashBeforePath + path); } } }