mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-22 16:03:22 +01:00
Add check-swap-space.ps1
This commit is contained in:
parent
5cb182921c
commit
73f0adffe6
23
Scripts/check-swap-space.ps1
Executable file
23
Scripts/check-swap-space.ps1
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/powershell
|
||||
<#
|
||||
.SYNTAX ./check-swap-space.ps1 [<warning-level>]
|
||||
.DESCRIPTION checks the swap space
|
||||
.LINK https://github.com/fleschutz/PowerShell
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
param([int]$WarningLevel = 50) # warning level in GB
|
||||
|
||||
try {
|
||||
$colItems = get-wmiobject -class "Win32_PageFileUsage" -namespace "root\CIMV2" -computername localhost
|
||||
|
||||
foreach ($objItem in $colItems) {
|
||||
$allocate = $objItem.AllocatedBaseSize
|
||||
$current = $objItem.CurrentUsage
|
||||
}
|
||||
write-host ($allocate - $current)
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
Loading…
Reference in New Issue
Block a user