Memory Informationen: Unterschied zwischen den Versionen

Aus Wiki-WebPerfect
Wechseln zu: Navigation, Suche
(Die Seite wurde neu angelegt: „<source lang="powershell"> Function Test-MemoryUsage { [cmdletbinding()] Param() $os = Get-Ciminstance Win32_OperatingSystem $pctFree = [math]::Round(($…“)
 
 
(4 dazwischenliegende Versionen des gleichen Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
 +
== Plain Memory Info ==
 
<source lang="powershell">
 
<source lang="powershell">
Function Test-MemoryUsage {
+
$MemoryInGB = [math]::Round((Get-Ciminstance Win32_OperatingSystem).TotalVisibleMemorySize/1mb,2)
 +
$MemoryInMB = $MemoryInGB * 1024
 +
$MemoryInMB
 +
</source>
 +
 
 +
 
 +
 
 +
== Get Memory Usage ==
 +
<source lang="powershell">
 +
Function Get-MemoryUsage {
 
[cmdletbinding()]
 
[cmdletbinding()]
 
Param()
 
Param()
+
 
$os = Get-Ciminstance Win32_OperatingSystem
 
$os = Get-Ciminstance Win32_OperatingSystem
 
$pctFree = [math]::Round(($os.FreePhysicalMemory/$os.TotalVisibleMemorySize)*100,2)
 
$pctFree = [math]::Round(($os.FreePhysicalMemory/$os.TotalVisibleMemorySize)*100,2)
+
 
if ($pctFree -ge 45) {
 
if ($pctFree -ge 45) {
 
$Status = "OK"
 
$Status = "OK"
Zeile 16: Zeile 26:
 
$Status = "Critical"
 
$Status = "Critical"
 
}
 
}
 
$os | Select @{Name = "Status";Expression = {$Status}},
 
@{Name = "PctFree"; Expression = {$pctFree}},
 
@{Name = "FreeGB";Expression = {[math]::Round($_.FreePhysicalMemory/1mb,2)}},
 
@{Name = "TotalGB";Expression = {[int]($_.TotalVisibleMemorySize/1mb)}}
 
 
   
 
   
 +
$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)}}
 
}
 
}
 
</source>
 
</source>
 +
 +
 +
 +
== Get 15 process with most Committed Memory Pages ==
 +
<source lang="powershell">Get-Process | Sort PagedMemorySize -Desc | Select Name, ID, @{Name="CommittedGB";e={[math]::Round($_.PagedMemorySize/1mb,2)}} -First 15 </source>
 +
 +
 +
 +
 +
 +
 +
 +
 +
[[Kategorie:PowerShell]]

Aktuelle Version vom 25. Februar 2019, 09:26 Uhr

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