Created
June 1, 2016 17:46
-
-
Save trayburn/50e610d1de18ee78954a118faba54bf9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ((Get-Process -Name slack -ErrorAction SilentlyContinue) -ne $null) { | |
$totalMemory = gwmi Win32_OperatingSystem | select -ExpandProperty TotalVisibleMemorySize | |
$slackMemory = (get-process slack | measure -Sum WS | select -ExpandProperty Sum) / 1024 | |
$slackExecutable = (Get-Process -Name slack | select -First 1).path | |
if (($slackMemory / $totalMemory) -ge .1) { | |
Get-Process slack | Stop-Process | |
Start-Process $slackExecutable | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment