Add modules from WinAPI

This commit is contained in:
Alex Kup 2023-12-19 00:06:14 +03:00 committed by GitHub
parent bbfdb5d61f
commit 27a1568d53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 54 additions and 9 deletions

View file

@ -1,15 +1,17 @@
function Get-MemorySize {
$Memory = Get-CimInstance Win32_OperatingSystem
$MemUse = $Memory.TotalVisibleMemorySize - $Memory.FreePhysicalMemory
$MemUserProc = ($MemUse / $Memory.TotalVisibleMemorySize) * 100
$GetProcess = Get-Process
$ws = ((($GetProcess).WorkingSet | Measure-Object -Sum).Sum/1gb).ToString("0.00 GB")
$pm = ((($GetProcess).PM | Measure-Object -Sum).Sum/1gb).ToString("0.00 GB")
$CollectionMemory = New-Object System.Collections.Generic.List[System.Object]
$CollectionMemory.Add([PSCustomObject]@{
MemoryAll = ($memory.TotalVisibleMemorySize/1mb).ToString("0.00 GB")
MemoryUse = ($MemUse/1mb).ToString("0.00 GB")
WorkingSet = $ws
PageMemory = $pm
MemoryAll = ($memory.TotalVisibleMemorySize/1mb).ToString("0.00 GB")
MemoryUse = ($MemUse/1mb).ToString("0.00 GB")
MemoryUseProc = [string]([int]$MemUserProc)+" %"
WorkingSet = $ws
PageMemory = $pm
})
$CollectionMemory
}