Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. Function AdapterSwitcher {
  2.  
  3. While ($true) {
  4.  
  5. $Ethernet = Get-NetAdapter | where-object {$_.Status -contains "Up"} | Where-Object {$_.PhysicalMediaType -eq "802.3" -and {$_.Name -notlike "PANGP" }}
  6. if ($Ethernet -eq $null)
  7. {
  8. Write-Host "Ethernet Not Detected, Enabling WiFi"
  9. #When the value is null this means that there is no wired connection and the wireless must be enabled
  10. $WiFiNetadapter = get-netadapter | where-object {$_.Status -contains "Up"} | Where-Object {$_.PhysicalMediaType -eq "Native 802.11"}
  11. $WiFiNetadapter | Enable-NetAdapter -Confirm:$false -Verbose
  12.  
  13.  
  14. }
  15. else
  16. {
  17. Write-Host "Disabling WiFi Network Adapter"
  18. #When the value is not null, the value consists of the object information about the Local Area Network Connection and
  19. #that the wireless connection needs to be disabled.
  20. $WiFiNetadapter = get-netadapter | where-object {$_.Status -contains "Up"} | Where-Object {$_.PhysicalMediaType -eq "Native 802.11"}
  21. $WiFiNetadapter | Disable-NetAdapter -Confirm:$false -Verbose }
  22. Start-Sleep -s 2
  23. }
  24. Start-Sleep -s 3
  25. }
  26.  
  27. #Remove-Variable -Name WIRED -Force
  28.  
  29. AdapterSwitcher
  30.  
  31. write-host "Disabling Network Adapter"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement