Home > Software engineering >  Powershell command for converting the cpu utilization to percentage
Powershell command for converting the cpu utilization to percentage

Time:11-23

Get-Process -Name(particular) .* | Format-Table -Property ProcessName,CPU

Get-Process -Name cbft.* | select -Property ProcessName,CPU | Sort-Object CPU -Descending

please help how to convert the CPU utilization to percentage

Please share the PowerShell command for covert CPU utilization to percentage

CodePudding user response:

Try the following:

$ProcessName = “process_name”
$CpuCores = (Get-WMIObject Win32_ComputerSystem).NumberOfLogicalProcessors
$Samples = (Get-Counter “\Process($Processname*)\% Processor 
Time”).CounterSamples
$Samples | Select InstanceName,
@{Name=”CPU %”;Expression={[Decimal]::Round(($_.CookedValue / $CpuCores), 2)}}
  • Related