I want to filter my output. If I get the result of the following script. How I can result specifix process? - here my proprosal, but it doesent work:
Function Get-CPUProcess
{
$properties=@(
@{Name="Name"; Expression = {$_.name}},
@{Name="PID"; Expression = {$_.IDProcess}},
@{Name="CPU (%)"; Expression = {$_.PercentProcessorTime}},
@{Name="Memory (MB)"; Expression = {[Math]::Round(($_.workingSetPrivate / 1mb),2)}}
@{Name="Disk (MB)"; Expression = {[Math]::Round(($_.IODataOperationsPersec / 1mb),2)}}
@{Name="Path";Expression = {(Get-Process -Id $_.IDProcess).Path}}
)
$ProcessCPU = Get-WmiObject -class Win32_PerfFormattedData_PerfProc_Process |
Select-Object $properties |
Sort-Object "CPU (%)" -desc |
Select-Object -First 5 |
Format-Table -AutoSize
$ProcessCPU
}
Get-CPUProcess -Filter {processname -like "firefox*"} | select * | Out-File C:filename.txt
See Question&Answers more detail:os