Created
September 13, 2018 16:58
-
-
Save JPRuskin/d49c229b79b7bf4c2f108a057aa742a4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
param( | |
$LessThan = 5, | |
$ForMinutes = 5 | |
) | |
$Continuing = $true | |
$NetBytes = '\Network Interface(*)\Bytes Received/sec' | |
$Count = 0 | |
while ($Continuing) { | |
$Down = (Get-Counter -Counter $NetBytes).CounterSamples.CookedValue / 1MB | |
if ($Down -le $LessThan) { | |
$Count++ | |
} else { | |
$Count = 0 | |
} | |
Write-Host "$(Get-Date): $($Down)MB/s $(if ($Count -gt 0) {"(Count $Count)"})" | |
if ($Count -ge $ForMinutes) { | |
Write-Host "Shutting down." | |
$Continuing = $false | |
Stop-Computer -Force | |
} | |
Start-Sleep -Seconds 60 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment