PowerShell script to suspend Windows screensaver at specific locations

Say that you are working with two laptops side by side. You may not like the automatic screensaver kicking in on a laptop while you are momentarily working on the other, in particular if it requires a password to unlock. This may be especially true at certain locations that are trusted (e.g. home).

The following PowerShell script for Windows can be used for suspending the screensaver when you are connected to a specific Wi-Fi network.

$wsh = New-Object -ComObject WScript.Shell
# Idea to use WSH comes from: https://stackoverflow.com/questions/9794893/powershell-toggle-num-lock-on-and-off

while ($true) {
    $wifi = get-netconnectionprofile | Out-String -Stream | Select-String -Pattern "<NAME_OF_YOUR_WIFI_NETWORK>"
    if ($wifi) {
    Start-Sleep -Seconds 60

Leave a Reply

Your email address will not be published. Required fields are marked *