Using PowerShell and Windows Network QoS Policies to Throttle Web-Based Downloads
I wrote a series of Twitter messages this morning with a couple quick how-to steps, but I figured it would be valuable to summarize in a quick blog post. Back in the day I used web Download Managers to throttle bandwidth usage so I didn’t interrupt other traffic on the LAN/WAN. While a LAN/WAN QoS network appliance based approach is the best approach, this capability is built into Windows and PowerShell! Additionally, this can be turned on and off very simply with minimal configuration, so if you’re in an internal or customer environment conducting downloads, you can very quickly set some policies to ensure you don’t trample all other traffic on the internet pipe.
Check out a very simple batch script that I wrote that will throttle all Web downloads (HTTP and HTTPS) down to 100KB:
powershell.exe -executionpolicy bypass “New-netqospolicy -Name ‘HTTP’ -IPPort 80 -IPProtocol TCP -ThrottleRateActionBitsPerSecond 100KB”
powershell.exe -executionpolicy bypass “New-netqospolicy -Name ‘HTTPS’ -IPPort 443 -IPProtocol TCP -ThrottleRateActionBitsPerSecond 100KB”
pause
You can modify “100KB” to any percentage of your total bandwidth available, but this is a quick tip to ensure you don’t destroy the user experience of others while performing large transfers.
This is a permanent bandwidth throttle policy that will stay in place until manually removed. To remove, simply run ‘Remove-NetQosPolicy “HTTPS” -a’ and ‘Remove-NetQosPolicy “HTTP” -a’ from an elevated PowerShell prompt. To view, you can run Get-NetQosPolicy to see all QoS policies in place.
The following is a before and after QoS Policy view in Task Manager.
Hope this quick tip has helped and brightened your Friday!
As always, if you have any questions, comments, or just want to leave feedback, please do so below. Thanks for reading!
thanks a lot, this may help on my internet cafe