Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,6 @@ internal enum MatchMode
/// </summary>
internal MatchMode myMode = MatchMode.All;

/// <summary>
/// The computer from which to retrieve processes.
/// </summary>
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
protected string[] SuppliedComputerName { get; set; } = Utils.EmptyArray<string>();

/// <remarks>
/// The Name parameter is declared in subclasses,
/// since it is optional for GetProcess and mandatory for StopProcess.
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -292,19 +275,7 @@ internal Process[] AllProcesses
if (null == _allProcesses)
{
List<Process> processes = new List<Process>();

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;
Expand Down Expand Up @@ -555,29 +526,6 @@ public SwitchParameter IncludeUserName
}
private bool _includeUserName = false;


/// <summary>
/// gets/sets the destination computer name
/// </summary>
[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;
}
}


///<summary>
///To display the modules of a process
///</summary>
Expand Down Expand Up @@ -621,13 +569,6 @@ protected override void BeginProcessing()
/// </summary>
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
Expand Down