Skip to content

Instantly share code, notes, and snippets.

@0XDE57
Last active December 20, 2016 06:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0XDE57/772cecdc709c3f49ea8f93797056a59a to your computer and use it in GitHub Desktop.
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
# 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