2
I was wondering if a batch script existed for automatically disabling an ethernet adaptor and enabling a wifi adaptor, I imagine that it'll require some fiddling with id's etc.
The reason for this is that my ethernet internet is metered, while my wifi is not. Hence I would like some easy way of switching between the two depending on whether I need the low packet loss of the ethernet connection.
The other possibility is whether there is a way to set certain programs to ignore an adaptor, i.e. make google chrome etc. not use ethernet, while everything else defaults to etherent?
End Result thanks to Seth
if( (Get-NetAdapter -Name "WiFi").Status -eq "Disabled"){
Disable-NetAdapter -Name "Ethernet"
Enable-NetAdapter -Name "Wifi"
"Wifi enabled, Ethernet disabled"
}else{
Disable-NetAdapter -Name "Wifi"
Enable-NetAdapter -Name "Ethernet"
"Ethernet enabled, Wifi disabled"
}
The reason that it checks for disabled rather than enabled, is due to there not being a status enabled (that I could see in my speed read) (that status is split into connecting etc.).
For my own convenience I made it into a batch file using the -EncodedCommand
flag for powershell.
Thanks thats just about perfect, just after I posted this I kind of realised that powershell maybe has a something and what you're answered is basically what I was starting to write so thanks for saving me a tonne of time. – Cjen1 – 2016-11-07T14:02:51.233
You will have to verify whenever
Get-NetAdapter
does expose an "Enabled" member or similar, as I said I don't have Windows 10 available right now. ;) – Seth – 2016-11-07T14:06:35.857Yeah I'm having a look into it – Cjen1 – 2016-11-07T14:10:15.857
So it is exposed, but the issue is that disable/enable aren't doing anything, still looking into it, thanks for your help so far – Cjen1 – 2016-11-07T14:12:31.487
Better do
gcm -noun netadapter
to get on the right track – LotPings – 2016-11-07T14:30:03.9971So I got the script finished and working, I'm going to post the result in the bottom of my question – Cjen1 – 2016-11-07T14:42:42.620