Add modules from WinAPI (process managment and cim hardware)

This commit is contained in:
Alex Kup 2023-12-12 16:39:28 +03:00 committed by GitHub
parent 3514ec6e3d
commit bbfdb5d61f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 243 additions and 0 deletions

View file

@ -0,0 +1,29 @@
function Get-ProcessDescription {
param (
$ProcessName
)
if ($null -eq $ProcessName) {
$GetProcess = Get-Process -ErrorAction Ignore
}
else {
$GetProcess = Get-Process -Name $ProcessName -ErrorAction Ignore
}
if ($null -ne $GetProcess) {
$GetProcess | Sort-Object -Descending CPU | Select-Object ProcessName,
@{Name="TotalProcTime"; Expression={$_.TotalProcessorTime -replace "\.\d+$"}},
@{Name="UserProcTime"; Expression={$_.UserProcessorTime -replace "\.\d+$"}},
@{Name="PrivilegedProcTime"; Expression={$_.PrivilegedProcessorTime -replace "\.\d+$"}},
@{Name="WorkingSet"; Expression={[string]([int]($_.WS / 1024kb))+" MB"}},
@{Name="PeakWorkingSet"; Expression={[string]([int]($_.PeakWorkingSet / 1024kb))+" MB"}},
@{Name="PageMemory"; Expression={[string]([int]($_.PM / 1024kb))+" MB"}},
@{Name="VirtualMemory"; Expression={[string]([int]($_.VM / 1024kb))+" MB"}},
@{Name="PrivateMemory"; Expression={[string]([int]($_.PrivateMemorySize / 1024kb))+" MB"}},
@{Name="RunTime"; Expression={((Get-Date) - $_.StartTime) -replace "\.\d+$"}},
@{Name="Threads"; Expression={$_.Threads.Count}},
Handles,Path
}
}
# Get-ProcessDescription *
# Get-ProcessDescription *torrent*
# Get-ProcessDescription qbittorrent