December 26, 2015
While away on holiday I ran into the problem of having maintenance scripts that downloads a lot of stuff from the internet. This can be a really big problem if you are connected over a metered 4G connection.
So I figured no problems I will just add a check to the start of the script to check for metered internet connections. Turns out this is actually a lot harder than I originally thought because there is no native Powershell way to do this.
So after playing around with some c# code I found to do this here I was able to turn it into a function Test-NetMetered which will return true or false based on if the internet connection is metered or not.
Full source code here: github.com/wiltaylor/NetMetered
I have also uploaded it in a module to the PSGallery so you can install it with the following:
Install-Module -Name NetMetered