PowerShell: Prevent screen saver, lock: Move mouse regularly
Alternatively, if you can't change the screen lock settings, you can move the mouse regularly, or have a script move the mouse. Originally published as an AutoIt script, I recreated the script with a few PowerShell lines. Anyone who copies the following commands into a PowerShell session will prevent the computer from locking the screen or starting the screensaver:
Add-Type -AssemblyName System.Windows.Forms
while ($true)
{
$Pos = [System.Windows.Forms.Cursor]::Position
[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point(($pos.X+1), ($pos.Y+1))
[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point($pos.X, $pos.Y)
Start-Sleep -Seconds 60
}
To run: Copy content to clipboard and:
The script moves the mouse one pixel and back every 60 seconds.

{{percentage}} % positive

THANK YOU for your review!
Top articles in this section
Log files in PowerShell can be created via the Out-File command, via a custom function, or via PowerShell's built-in Transcript.
PowerShell uses the following commands to open a socket on a specific port via System.NET:
A scheduled task in Windows can of course also be created via PowerShell.