Skip to content

Instantly share code, notes, and snippets.

@JPRuskin
Created September 13, 2018 16:58
Show Gist options
  • Save JPRuskin/d49c229b79b7bf4c2f108a057aa742a4 to your computer and use it in GitHub Desktop.
Save JPRuskin/d49c229b79b7bf4c2f108a057aa742a4 to your computer and use it in GitHub Desktop.
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