Click on Pictures to View

To view a larger version of an image within a post, just click on the picture you want to view :)

Wednesday, December 12, 2018

Enable or Disable HP Laptop LAN/WLAN Switching in BIOS via PowerShell

So HP laptops, at least, usually have a feature described as LAN/WLAN switching.  This essentially disables the wireless when a LAN cable is attached to the laptop, and enables the wireless when the LAN cable is disconnected.

This feature can help avoid laptops needing both LAN & wireless IP addresses, and since LAN speeds are typically faster so forcing the machine to use the wire instead of wireless is also a benefit.

You can boot into the BIOS and look for the feature in order to enable it, which can get cumbersome and tricky if you are using Windows 10.

This PowerShell script checks the HP BIOS for feature "LAN/WLAN Switching", verifies if it is already enabled, or enables LAN/WLAN switching if it is not already enabled.

You can type this in a text document, then save it as a powershell instead of text file, e.g. lanwlan.ps1




Then simply run the PowerShell script twice (first to change, then to confirm) and rebooted the machine once.


There was an instance, however, where I needed both the wireless and wire to work simultaneously for my test laptop so that I could relatively remotely run a packet capture (so the laptop's LAN was connected to a SPAN port, and its wireless needed to be enabled so I could RDP to a valid IP on the laptop in the tiny network closet).

I simply reversed the script to choose "If the LAN/WLAN switching is Disabled, return Correct, otherwise Disable the feature."





I ran the script and rebooted the test laptop and voila, the feature was disabled without going into the BIOS itself.








Scripts below.


Disable_LANWLANAutoSwitching.ps1

$Interface = Get-WmiObject HP_BIOSEnumeration -Namespace "ROOT\HP\InstrumentedBIOS"  | where Name -eq "LAN / WLAN Auto Switching" | Select value
If ($Interface.value -eq "*Disabled,Enabled")
{
$Interface
}
Else
{
$Setting = Get-WmiObject -Namespace "ROOT\HP\InstrumentedBIOS" -Class HP_BIOSSettingInterface
$Setting.SetBIOSSetting("LAN / WLAN Auto Switching","Disabled","")
}


Enable_LANWLANAutoSwitching.ps1

$Interface = Get-WmiObject HP_BIOSEnumeration -Namespace "ROOT\HP\InstrumentedBIOS"  | where Name -eq "LAN / WLAN Auto Switching" | Select value
If ($Interface.value -eq "Disabled,*Enabled")
{
$Interface
}
Else
{
$Setting = Get-WmiObject -Namespace "ROOT\HP\InstrumentedBIOS" -Class HP_BIOSSettingInterface
$Setting.SetBIOSSetting("LAN / WLAN Auto Switching","Enabled","")
}






For legacy versions:


LANWLANdisable.ps1

$lan = gwmi HP_BIOSSetting -Namespace "root\HP\InstrumentedBIOS"  | where {$_.name -eq "LAN/WLAN Switching"} | Select value
If ($lan.value -eq " *Disable, Enable")
{
"LAN/WLAN Correct"
}
Else
{
$s = gwmi -class hp_biossettinginterface -Namespace "root\hp\instrumentedbios"
$s.SetBIOSSetting("LAN/WLAN Switching","Disable","")
}




LANWLANenable.ps1



$lan = gwmi HP_BIOSSetting -Namespace "root\HP\InstrumentedBIOS"  | where {$_.name -eq "LAN/WLAN Switching"} | Select value
If ($lan.value -eq " Disable, *Enable")
{
"LAN/WLAN Correct"
}
Else
{
$s = gwmi -class hp_biossettinginterface -Namespace "root\hp\instrumentedbios"
$s.SetBIOSSetting("LAN/WLAN Switching","Enable","")
}