Using Powershell to make your screensaver never lock

 


The following script simply toggles the SCROLL-LOCK key every 4 minutes with a .1s double click.

To use: save this as a Powershell script (ending with .ps1) and then run it. Once open, just minimize the script window. It'll still run fine minimized.

clear-host
Echo "Keep alive with scroll lock"
$WShell = New-Object -com "WScript.shell"
while ($True)
{
  $WShell.sendkeys("{SCROLLLOCK}")
  start-sleep -Milliseconds 100
  $WShell.sendkeys("{SCROLLLOCK}")
  start-sleep -Seconds 240
}

An alternative script I wrote gives more detail. I have it pressing the Num Lock Key on a random schedule from 0 to 30 minutes.

cls
Echo "Keep alive with NUMLOCK"
$WShell = New-Object -com "WScript.shell"
while ($True)
{
  $rand=Get-Random -Maximum 1800
  $randminutes=$rand/60
  $ts = New-TimeSpan -Seconds $rand
  Write-Host  "$([math]::Round($randminutes,2)) Minutes Start($(Get-Date)) End($((Get-Date)+$ts))"  
  $WShell.sendkeys("{NUMLOCK}")
  start-sleep -Seconds $rand
}

Source: https://www.reddit.com/r/sysadmin/comments/th1me3/make_ms_teams_never_show_away_with_this/

Share on Google Plus

About Tom DeMeulenaere

Highly accomplished information technology professional with extensive knowledge in System Center Configuration Manager, Windows Server, SharePoint, and Office 365.
    Blogger Comment

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.