Keep your Windows sessions alive and ready with this PowerShell script

3 years ago 273

Make definite your Windows systems are afloat disposable and acceptable to rotation with assistance from a elemental PowerShell script.

Powershell

Image: iStock/BestForBest

Those of america who trust connected and administer Windows systems for enactment are good alert of the assorted benefits and challenges bestowed upon america by Microsoft. For the astir part, I'm satisfied with the default Windows settings, but each erstwhile successful a portion I request to marque changes to my surface saver, slumber mode and surface fastener settings for maximum efficiency. 

It's casual capable to bash this if you're an head connected the strategy (such arsenic your idiosyncratic computer).

SEE: 20 bully habits web administrators need--and 10 habits to interruption (free PDF) (TechRepublic)

How to set Screen Saver settings

Right-click Start, spell to Settings, hunt for Turn Screen Saver On Or Off and marque the desired changes (Figure A).

Figure A

screensaver.jpg

How to set Sleep Mode settings

Right-click Start, spell to Settings, take System and past Power & Sleep and marque the desired changes (Figure B).

Figure B

power-and-sleep.jpg

How to set Screen Lock settings utilizing this PowerShell publication

This useful article explains however you tin marque a indispensable registry alteration past tweak this setting. It besides provides a reliable registry record you tin import to your machine to marque the alteration for you.

If you're utilizing a company-owned strategy oregon 1 you ain that operates nether a Bring Your Own Device policy, apt determination volition beryllium centralized controls applied to this lawsuit of Windows that you can't control–namely, automated surface locking, distant desktop league logoffs oregon slumber mode powerfulness options. All of these footwear successful aft a play of inactivity, and it tin beryllium frustrating and clip consuming to person to participate passwords repeatedly, reconnect to mislaid sessions oregon hold for a strategy to travel retired of slumber mode truthful you tin resume your work.

With that successful mind, this PowerShell publication tin assistance support your Windows logons progressive and acceptable for work. It simply activates past deactivates the Scroll Lock fastener each 4 minutes. This sends a awesome to the operating strategy that idiosyncratic (technically something) is utilizing the machine and frankincense your league remains alive.

I privation to accent that I don't urge circumventing information settings mandated for concern operations–not lone mightiness that interruption policy, but it tin get workers successful trouble. However, for a work-from-home environment, oregon erstwhile connecting to a distant Windows strategy via Remote Desktop, this publication tin beryllium a harmless blessing to assistance support productivity. Just beryllium mindful of the information if you tally it connected your section machine your Windows sessions volition beryllium afloat disposable to anyone who accesses the keyboard and mouse, whether it's you oregon not. But you tin inactive fastener your surface utilizing the Windows-L cardinal operation and past unlock it with your password.

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

To usage the script, transcript the codification below, unfastened up Notepad (right-click Start, take Run, participate notepad and deed Enter) and paste it into the substance editor. Save the publication arsenic "keepalive" (or immoderate sanction you choose) and adhd the .ps1 extension. Note: You should acceptable the Save As Type tract to All Files, lest Notepad prevention the publication arsenic keepalive.ps1.txt (Figure C).

Figure C

saveas.jpg

Right-click the publication record and take Run With PowerShell to tally it (or transcript it to the people Windows instrumentality you privation to tally it on). You volition spot the Windows PowerShell surface (Figure D).

Figure D

script.jpg

The publication indispensable stay moving successful bid to enactment for you, but you tin minimize this window.

SEE: Checklist: Server inventory (TechRepublic Premium)

If you person issues moving it with the PowerShell executable, effort PowerShell Integrated Scripting Environment (ISE). Open the Start Menu, scroll down to Windows PowerShell, grow that folder and unfastened Windows PowerShell ISE. Browse to the publication record utilizing File past Open and double-click it and past click the greenish Play icon successful the toolbar truthful it runs (Figure E).

Figure E

scriptise.jpg
Clear-Host Echo "Keep live w/ scroll lock..." $WShell = New-Object -com "Wscript.Shell" while ($true) { $WShell.sendkeys("{SCROLLLOCK}") Start-Sleep -Milliseconds 100 $WShell.sendkeys("{SCROLLLOCK}") Start-Sleep -Seconds 240 }

Microsoft Weekly Newsletter

Be your company's Microsoft insider by speechmaking these Windows and Office tips, tricks, and cheat sheets. Delivered Mondays and Wednesdays

Sign up today

Also spot

Read Entire Article