Auto Connect to WiFi access points

The following script is very handy for any Windows machine which relies on Wi-Fi, wireless or LTE 4G networks. WiFi at the best of times is not that reliable and you can experience WiFi dropouts or Wi-Fi disconnections. You can now have a full automatic solution which keeps a Windows machine connected to WiFi even if the connection drops.

Running this AutoConnectWiFi.ps1 script (below) will ensure that the Windows device is actually connected to a known WiFi network. A known WiFi network is a network in which the device has already connected to in the past and is aware of both the Wireless SSID and passphrase.

2017-03-16_1002

The script has the smarts to connect only to the strongest known network.

If the script runs and the Windows device is already connected to any WiFi network, then the script will essentially do nothing and simply end gracefully, so it is safe to run this multiple times as peice of mind to make sure the device never drops a Wireless network connection.

To add this script above as a scheduled task, run the script below (ScheduledTask-Event-Repeat.ps1). The PowerShell script below will attach a specific Windows Event to a scheduled task and in turn run a PowerShell script when event ID 8003 (WiFi disconnection) is logged in the event log.

In other words, as soon as the WiFi network is disconnected, the scheduled task is kicked off running the AutoConnectWiFi.ps1 script.

Run this PowerShell script as administrator to ensure you have the privileges necessary to add a scheduled task.

PowerShell

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: