From 151d078b24926ae3f32a5a1573b4557ecdefc476 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Fri, 29 Sep 2017 22:05:50 -0700 Subject: [PATCH] [feature] remove -computer support since corefx Process.GetProcesses(computer) returns local processes --- .../commands/management/Process.cs | 65 +------------------ 1 file changed, 3 insertions(+), 62 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs index a49c5f7a2f6..c5f3e46cf69 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs @@ -69,12 +69,6 @@ internal enum MatchMode /// internal MatchMode myMode = MatchMode.All; - /// - /// The computer from which to retrieve processes. - /// - [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] - protected string[] SuppliedComputerName { get; set; } = Utils.EmptyArray(); - /// /// The Name parameter is declared in subclasses, /// since it is optional for GetProcess and mandatory for StopProcess. @@ -228,19 +222,8 @@ private void RetrieveMatchingProcessesById() Process process; try { - if (SuppliedComputerName.Length > 0) - { - foreach (string computerName in SuppliedComputerName) - { - process = Process.GetProcessById(processId, computerName); - AddIdempotent(process); - } - } - else - { - process = Process.GetProcessById(processId); - AddIdempotent(process); - } + process = Process.GetProcessById(processId); + AddIdempotent(process); } catch (ArgumentException) { @@ -292,19 +275,7 @@ internal Process[] AllProcesses if (null == _allProcesses) { List processes = new List(); - - if (SuppliedComputerName.Length > 0) - { - foreach (string computerName in SuppliedComputerName) - { - processes.AddRange(Process.GetProcesses(computerName)); - } - } - else - { - processes.AddRange(Process.GetProcesses()); - } - + processes.AddRange(Process.GetProcesses()); _allProcesses = processes.ToArray(); } return _allProcesses; @@ -555,29 +526,6 @@ public SwitchParameter IncludeUserName } private bool _includeUserName = false; - - /// - /// gets/sets the destination computer name - /// - [Parameter(Mandatory = false, ParameterSetName = NameParameterSet, ValueFromPipelineByPropertyName = true)] - [Parameter(Mandatory = false, ParameterSetName = IdParameterSet, ValueFromPipelineByPropertyName = true)] - [Parameter(Mandatory = false, ParameterSetName = InputObjectParameterSet, ValueFromPipelineByPropertyName = true)] - [Alias("Cn")] - [ValidateNotNullOrEmpty()] - [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] - public string[] ComputerName - { - get - { - return SuppliedComputerName; - } - set - { - SuppliedComputerName = value; - } - } - - /// ///To display the modules of a process /// @@ -621,13 +569,6 @@ protected override void BeginProcessing() /// protected override void ProcessRecord() { - if (ComputerName.Length > 0 && (FileVersionInfo.IsPresent || Module.IsPresent)) - { - Exception ex = new InvalidOperationException(ProcessResources.NoComputerNameWithFileVersion); - ErrorRecord er = new ErrorRecord(ex, "InvalidOperationException", ErrorCategory.InvalidOperation, ComputerName); - ThrowTerminatingError(er); - } - foreach (Process process in MatchingProcesses()) { //if module and fileversion are to be displayed