Last active
December 20, 2016 06:15
-
-
Save 0XDE57/772cecdc709c3f49ea8f93797056a59a to your computer and use it in GitHub Desktop.
Restart wifi adapter on laptop after waking from sleep. Solution to some strange driver bug on win7 x86 Intel n7620 wifi card. Auto run on wake up with Task Scheduler: On Event > System > Kernel-Power > 42
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get the network adapter object | |
$adapter = Get-WmiObject -Class Win32_NetworkAdapter | Where-Object {$_.Name -eq "Intel(R) Wireless-N 7260"} | |
# Disable it | |
Write-Host -nonew "Disabling Network Adapter $($adapter.Name) ... "; | |
$result = $adapter.Disable() | |
if ($result.ReturnValue -eq -0) { | |
Write-Host "Success."; | |
} else { | |
Write-Host "Failed."; | |
} | |
# Wait 2 seconds | |
Start-Sleep -s 2 | |
# Enable it | |
Write-Host -nonew "Enabling Network Adapter $($adapter.Name)... "; | |
$result = $adapter.Enable() | |
if ($result.ReturnValue -eq -0) { | |
Write-Host "Success."; | |
} else { | |
Write-Host "Failed."; | |
} | |
# Wait 2 seconds | |
Start-Sleep -s 2 | |
$NICs = Get-WmiObject -Class Win32_NetworkAdapterConfiguration | Where {$_.IPEnabled -eq "TRUE"} | |
Foreach($NIC in $NICs) { | |
Write-Host -nonew "Enabling DHCP... "; | |
$NIC.EnableDHCP() | |
$NIC.SetDNSServerSearchOrder() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment