Keep your Windows sessions alive and ready with this PowerShell script

Be sure that your Home windows methods are totally obtainable and able to roll with assist from a easy PowerShell script.


Picture: iStock/BestForBest

These of us who depend on and administer Home windows methods for work are properly conscious of the assorted advantages and challenges bestowed upon us by Microsoft. For probably the most half, I am happy with the default Home windows settings, however each from time to time I have to make modifications to my display saver, sleep mode and display lock settings for optimum effectivity. 

It is simple sufficient to do that for those who’re an administrator on the system (similar to your private laptop).

SEE: 20 good habits community directors need–and 10 habits to interrupt (free PDF) (TechRepublic)

The right way to regulate Display screen Saver settings

Proper-click Begin, go to Settings, seek for Flip Display screen Saver On Or Off and make the specified modifications (Determine A).

Determine A


The right way to regulate Sleep Mode settings

Proper-click Begin, go to Settings, select System after which Energy & Sleep and make the specified modifications (Determine B).

Determine B


The right way to regulate Display screen Lock settings utilizing this PowerShell script

This helpful article explains how one can make a vital registry change then tweak this setting. It additionally offers a dependable registry file you may import to your laptop to make the change for you.

In case you’re utilizing a company-owned system or one you personal that operates underneath a Deliver Your Personal System coverage, seemingly there will probably be centralized controls utilized to this occasion of Home windows you could’t management–particularly, automated display locking, distant desktop session logoffs or sleep mode energy choices. All of those kick in after a interval of inactivity, and it may be irritating and time consuming to must enter passwords repeatedly, reconnect to misplaced classes or watch for a system to return out of sleep mode so you may resume your work.

With that in thoughts, this PowerShell script will help maintain your Home windows logons energetic and prepared for work. It merely prompts then deactivates the Scroll Lock button each 4 minutes. This sends a sign to the working system that somebody (technically somefactor) is utilizing the pc and thus your session stays alive.

I need to stress that I do not suggest circumventing safety settings mandated for enterprise operations–not solely would possibly that violate coverage, however it may get staff in hassle. Nonetheless, for a work-from-home surroundings, or when connecting to a distant Home windows system by way of Distant Desktop, this script is usually a secure blessing to assist preserve productiveness. Simply be aware of the very fact for those who run it in your native laptop your Home windows classes will probably be totally obtainable to anybody who accesses the keyboard and mouse, whether or not it is you or not. However you may nonetheless lock your display utilizing the Home windows-L key mixture after which unlock it along with your password.

SEE: Microsoft PowerShell: Learn to automate your workday (TechRepublic Academy)

To make use of the script, copy the code beneath, open up Notepad (right-click Begin, select Run, enter notepad and hit Enter) and paste it into the textual content editor. Save the script as “keepalive” (or no matter title you select) and add the .ps1 extension. Be aware: It is best to set the Save As Sort subject to All Information, lest Notepad save the script as keepalive.ps1.txt (Determine C).

Determine C


Proper-click the script file and select Run With PowerShell to run it (or copy it to the goal Home windows machine you want to run it on). You will notice the Home windows PowerShell display (Determine D).

Determine D


The script should stay operating with a view to give you the results you want, however you may reduce this window.

SEE: Guidelines: Server stock (TechRepublic Premium)

When you’ve got points operating it with the PowerShell executable, strive PowerShell Built-in Scripting Setting (ISE). Open the Begin Menu, scroll all the way down to Home windows PowerShell, broaden that folder and open Home windows PowerShell ISE. Browse to the script file utilizing File then Open and double-click it after which click on the inexperienced Play icon within the toolbar so it runs (Determine E).

Determine E


Echo "Maintain alive w/ scroll lock..."

$WShell = New-Object -com "Wscript.Shell"

whereas ($true)



Begin-Sleep -Milliseconds 100


Begin-Sleep -Seconds 240


Additionally see

Recent Articles


Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here

Stay on op - Ge the daily news in your inbox