Alternatieve PowerShell oplossing: https://gallery.technet.microsoft.com/scriptcenter/WLAN-Manager-f438a4d7
WLAN Manager draait als een geplande taak en zal uw WLAN-kaart automatisch uitschakelen wanneer een LAN-verbinding wordt geverifieerd. Zodra de LAN-verbinding wordt verbroken, wordt de WLAN-kaart weer ingeschakeld. Dit zorgt ervoor dat u de snelst beschikbare verbinding hebt en helpt netwerk bridging te voorkomen.
Originele code door “substance” op Microsoft Technet. Zip file ](https://gallery.technet.microsoft.com/scriptcenter/WLAN-Manager-f438a4d7/file/134530/1/WLANManager.zip)
################
# WLAN Manager #
################
#Version: 2015-03-03.2
#Author: johan.carlsson@innovatum.se
<#
.SYNOPSIS
Disables the WLAN NIC when LAN NIC network connection is verified.
Enables WLAN NIC when LAN NIC network connection is lost.
.DESCRIPTION
WLAN Manager runs as a scheduled task and will automatically disable your WLAN card when a LAN connection is verified.
The WLAN card will be re-enabled once the LAN connection is lost. This ensures you'll always have the fastest available connection and stops network bridging.
.EXAMPLE
.\WLANManager.ps1 -Install:$true
Installs WLAN Manager.
.EXAMPLE
.\WLANManager.ps1 -Remove:$true
Removes WLAN Manager.
.EXAMPLE
.\WLANManager.ps1
Verify Installaton > Install if missing > Run Interactively (first run only, hidden run via scheduled task run after that).
.EXAMPLE
.\WLANManager.ps1 -Interactive:$true
Runs WLAN Manager in an interactive window. Will not install anything. This mode is only for testing and watching what happens via console output.
.NOTES
None.
.LINK
https://support.innovatum.se
#>
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$False,Position=1,HelpMessage="Installs WLAN Manager.")]
[switch]$Install,
[Parameter(Mandatory=$False,Position=2,HelpMessage="Removes WLAN Manager.")]
[switch]$Remove,
[Parameter(Mandatory=$False,Position=3,HelpMessage="Runs WLAN Manager interactively, doesn't install anything.")]
[switch]$Interactive
)
#########################################
# Custom Variables for Your Environment #
#########################################
#Destination Path to where you want to store files for local install of WLANManager
$CustomDestinationPath = "$env:ProgramFiles\WLANManager"
<#
D O N O T C H A N G E A N Y T H I N G B E L O W T H I S L I N E
#>
#################################
# Unload/Load PowerShell Module #
#################################
#Remove PowerShell Module
If ((Get-Module PSModule-WLANManager) -ne $null)
{
Remove-Module PSModule-WLANManager -Verbose
}
#Import PowerShell Module
$strBasePath = Split-Path -Path $MyInvocation.InvocationName
Import-Module "$strBasePath\PSModule-WLANManager.psm1" -Verbose
#############################
# Install or Update Install #
#############################
If ($Remove -eq $true)
{
Remove-WLANManager -FilePath $CustomDestinationPath
return
}
ElseIf ((Test-Path -Path $strBasePath) -eq $True -and ($Interactive) -ne $true)
{
#Install
Install-WLANManager -SourcePath $strBasePath -DestinationPath $CustomDestinationPath
If ($Install -eq $true)
{
#≥Windows 8
If ($OSInfo.Caption -match "Windows 8")
{
Start-ScheduledTask -TaskName "WLAN Manager"
Exit
}
#<Windows 8
Else
{
Start-STask -TaskName "WLAN Manager" | Out-Null
Exit
}
}
}
########
# Main #
########
while ($true)
{
If ((Test-WiredConnection) -eq $true -and (Test-WirelessConnection) -eq $true)
{
Write-Host "Wired connection detected, disabling Wireless connection... " -NoNewline -ForegroundColor Yellow
#≥Windows 8
If ($OSInfo.Caption -match "Windows 8")
{
Disable-NetAdapter -InterfaceDescription *Wireless* -Confirm:$false
}
#<Windows 8
Else
{
Disable-WLANAdapter | Out-Null
}
Write-Host "Done" -ForegroundColor White -BackgroundColor Green
}
If ((Test-WiredConnection) -eq $false -and (Test-WirelessConnection) -eq $false)
{
Write-Host "Wired connection lost, enabling Wireless connection... " -NoNewline -ForegroundColor Yellow
#≥Windows 8
If ($OSInfo.Caption -match "Windows 8")
{
Enable-NetAdapter -InterfaceDescription *Wireless* -Confirm:$false
}
#<Windows 8
Else
{
Enable-WLANAdapter | Out-Null
}
#Wait for WLAN Adapter to initialize and obtain an IP-address
while ((Test-WiredConnection) -eq $false -and (Test-WirelessConnection) -eq $false)
{
sleep -Seconds 1
}
Write-Host "Done" -ForegroundColor White -BackgroundColor Green
}
Else
{
Write-Host "Sleeping..." -ForegroundColor Yellow
sleep -Seconds 1
}
}