Skip to content

Instantly share code, notes, and snippets.

@Rob-Conan
Created August 3, 2015 17:01
Show Gist options
  • Save Rob-Conan/6e9ef3fc4469ed993861 to your computer and use it in GitHub Desktop.
Save Rob-Conan/6e9ef3fc4469ed993861 to your computer and use it in GitHub Desktop.
##
# Author: Rob Conan
# GitHub: Rob-Conan
#
#
# Powershell Script to enable/disable interfaces based on a users input
#
# To get a list of devices from powershell you need Devcon
# https://msdn.microsoft.com/en-us/library/windows/hardware/ff544707(v=vs.85).aspx
# Once installed run
# devcon listclass net
# to get a list of network adapaters
# replace your device ID's with those below
# Shorten the ID to be unique. This can be tested with
# devcon status "*VID_12D1*" < replace with your ID
##
#
# Define an input paramater
#
param([string]$mode= "")
#USB\VID_12D1&PID_14DB\6&25E77C2F&0&7
$4GAdapater = "*VID_12D1*"
#PCI\VEN_1969&DEV_E091&SUBSYS_78451462&REV_13\4&AE4B82D&0&00E3
$EthernetAdapter = "*DEV_E091*"
$ethernet = ""
$4g = ""
# Take in parameter to enable Ethernet
# If 4G is on
# Disable
# If Ethernet is off
# Enable
if ($mode -eq "ethernet"){
$ethernet = devcon status $EthernetAdapter | select-string "running"
$4g = devcon status $4GAdapater | select-string "running"
if ($ethernet -like '*running.*'){
echo "Ethernet is active"
}
else{
devcon enable $EthernetAdapter
echo "Ethernet adapter enabled"
}
if ($4g -like '*running.*'){
echo "Disabling 4G adapter"
devcon disable $4GAdapater
}
}
# Take in parameter to enable 4G
# If Ethernet on
# Disable Ehternet
# If 4G off
# Enable 4G
elseif ($mode -eq "4g"){
$ethernet = devcon status $EthernetAdapter | select-string "running"
$4g = devcon status $4GAdapater | select-string "running"
if ($4g -like '*running.*'){
echo "4G is active"
}
else{
devcon enable $4GAdapater
echo "4G adapter enabled"
}
if ($ethernet -like '*running.*'){
echo "Disabling Ethernet adapter"
devcon disable $EthernetAdapter
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment