Memory Informationen

Aus Wiki-WebPerfect
Version vom 25. Februar 2019, 09:26 Uhr von Admin (Diskussion | Beiträge)

(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Wechseln zu: Navigation, Suche

Plain Memory Info

$MemoryInGB = [math]::Round((Get-Ciminstance Win32_OperatingSystem).TotalVisibleMemorySize/1mb,2)
$MemoryInMB = $MemoryInGB * 1024
$MemoryInMB


Get Memory Usage

Function Get-MemoryUsage {
	[cmdletbinding()]
	Param()
 
	$os = Get-Ciminstance Win32_OperatingSystem
	$pctFree = [math]::Round(($os.FreePhysicalMemory/$os.TotalVisibleMemorySize)*100,2)
 
	if ($pctFree -ge 45) {
		$Status = "OK"
	}
	elseif ($pctFree -ge 15 ) {
		$Status = "Warning"
	}
	else {
		$Status = "Critical"
	}
 
	$os | Select @{Name = "Status";Expression = {$Status}},
    @{Name = "TotalGB";Expression = {[int]($_.TotalVisibleMemorySize/1mb)}},	
    @{Name = "FreeGB";Expression = {[math]::Round($_.FreePhysicalMemory/1mb,2)}},
    @{Name = "%Free"; Expression = {$pctFree}},	
    @{Name=’CommittedGB’;Expression={[math]::Round(($_.totalvirtualmemorysize – $_.freevirtualmemory)/1mb,2)}}
}


Get 15 process with most Committed Memory Pages

Get-Process | Sort PagedMemorySize -Desc | Select Name, ID, @{Name="CommittedGB";e={[math]::Round($_.PagedMemorySize/1mb,2)}} -First 15