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","")
}
i am getting return code 5
ReplyDeletesorry return code is 4
DeleteI get the same issue, where the return code is 4. Can anyone advise on this?
Delete$Interface = Get-WmiObject HP_BIOSEnumeration -Namespace "ROOT\HP\InstrumentedBIOS" | where Name -eq "LAN / WLAN Auto Switching" | Select value
DeleteIf ($Interface.value -eq "Disabled,*Enable")
{
$Interface
}
Else
{
$Setting = Get-WmiObject -Namespace "ROOT\HP\InstrumentedBIOS" -Class HP_BIOSSettingInterface
$Setting.SetBIOSSetting("LAN / WLAN Auto Switching","Enable","")
}
Hi, the above script will work, you need to change enabled to enable.
Return code 4 means Failed (Usually caused by a typo in the setting value)
Hope this helps everyone struggling with the script.
Thanks,
Damian
I get return code 6 when I use your script. Anyone know why this might be happening? I do have a bios password enabled.
Deletehey all, sorry I am late, I didn't realize anyone actually was reading this thing; per info shared from user Bill_Stewart (here https://social.msdn.microsoft.com/Forums/en-US/21d50e30-bdce-476c-830c-88b3c23c1bda/where-can-i-find-a-list-of-powershell-exit-codes?forum=scripting use) try the below to check what you return code info is:
ReplyDelete"Also the command: net helpmsg n
(where 'n' is an error code number) provides the localized description for common error codes."
Notice the syntax of the script could change based on the version of Windows OS and build. I neglected to take note which of these original ps scripts were working on. When I can I'll double check and update with info on that part or an updated script.
some of