Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function AdapterSwitcher {
- While ($true) {
- $Ethernet = Get-NetAdapter | where-object {$_.Status -contains "Up"} | Where-Object {$_.PhysicalMediaType -eq "802.3" -and {$_.Name -notlike "PANGP" }}
- if ($Ethernet -eq $null)
- {
- Write-Host "Ethernet Not Detected, Enabling WiFi"
- #When the value is null this means that there is no wired connection and the wireless must be enabled
- $WiFiNetadapter = get-netadapter | where-object {$_.Status -contains "Up"} | Where-Object {$_.PhysicalMediaType -eq "Native 802.11"}
- $WiFiNetadapter | Enable-NetAdapter -Confirm:$false -Verbose
- }
- else
- {
- Write-Host "Disabling WiFi Network Adapter"
- #When the value is not null, the value consists of the object information about the Local Area Network Connection and
- #that the wireless connection needs to be disabled.
- $WiFiNetadapter = get-netadapter | where-object {$_.Status -contains "Up"} | Where-Object {$_.PhysicalMediaType -eq "Native 802.11"}
- $WiFiNetadapter | Disable-NetAdapter -Confirm:$false -Verbose }
- Start-Sleep -s 2
- }
- Start-Sleep -s 3
- }
- #Remove-Variable -Name WIRED -Force
- AdapterSwitcher
- write-host "Disabling Network Adapter"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement