Skip to content

Instantly share code, notes, and snippets.

@trayburn
Created June 1, 2016 17:46
Show Gist options
  • Save trayburn/50e610d1de18ee78954a118faba54bf9 to your computer and use it in GitHub Desktop.
Save trayburn/50e610d1de18ee78954a118faba54bf9 to your computer and use it in GitHub Desktop.
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