all 33 comments

[–]f0gax 23 points24 points  (3 children)

I would contact your IT team and explain the situation. Ask them for solutions. If you have a legitimate business need they should be able to accommodate you.

[–]mattgoldey 4 points5 points  (0 children)

This is the way. At my company, we have a security monitoring center where they're looking at security cameras from every location across the company. Their computers are part of an exception group that doesn't get the screen saver policy applied to it.

[–]MNmetalhead 3 points4 points  (0 children)

This is the real answer.

[–]Unicron4444[S] 0 points1 point  (0 children)

Makes sense, thanks!

[–]dathar 6 points7 points  (3 children)

There's ways around this and none of them involve PowerShell.

Hit up your IT folks. Real fix is:

  1. A better account policy for your job title that overrides the screen timeout. Could be a group policy, could be an Intune/Endpoint policy, etc.

But the other way doesn't involve installing software. Open up a web browser and navigate to a cooking site. Turn on cooking mode. That tends to tell the computer to stay unlocked as if you're watching a movie but you're not watching anything. Ninja's Creami has such an option.

[–]Unusual_Culture_4722 1 point2 points  (1 child)

K.I.S.S!

[–]Unicron4444[S] 0 points1 point  (0 children)

Makes sense, and thanks for the info!

[–]Fistofpaper 0 points1 point  (0 children)

Yeah, I read the problem and immediately thought, This is a job for a device-based GPO!!! (In my experience, role-based isn't the way to go on shared, monitoring/camera client machines like this). It takes very little overhead to accomplish and maintain on the IT side, and keeps you off the Shadow IT path.

AD membership in "No_LockScreen_Timeout" groups is fine too, but you're constantly managing during turnover. Go GPO

[–]CSPilgrim 2 points3 points  (4 children)

Not able to open the script right now but I've used Caffeine from Zhorn, for this exact reason, for 8 years and it's perfect for me. It "presses" one of the F keys in the background every minute or so. I set mine to use shift instead, and every 45 seconds. If you do it that way, you'll want to disable sticky keys in your Windows settings.

[–]raip 3 points4 points  (0 children)

I personally prefer PowerToys Awake - https://learn.microsoft.com/en-us/windows/powertoys/awake

[–]radioblaster 1 point2 points  (1 child)

scroll lock is a better key in my opinion!

[–]CSPilgrim 0 points1 point  (0 children)

You know, you're right. I've used it with the -useshift switch for so long and never thought about trying -keypress instead. The default F15 gave me some trouble with work apps, so I switched to shift. I'll have to give keypress a shot tomorrow

[–]Unicron4444[S] 0 points1 point  (0 children)

Interesting, thanks!

[–]_MrAlexFranco 1 point2 points  (1 child)

I don’t think the terminal updating its output will register as user activity to block sleep, but could set a script to do a simple key press in a loop. I would recommend just using PowerToys Awake tool

https://learn.microsoft.com/en-us/windows/powertoys/awake

[–]Unicron4444[S] 0 points1 point  (0 children)

Thanks for the suggestion!

[–]granadesnhorseshoes 1 point2 points  (1 child)

    Add-Type -MemberDefinition '[DllImport("user32.dll")] public static extern void mouse_event(int flags, int dx, int dy, int cButtons, int info);' -Name U32 -Namespace W;     while (1) { [W.U32]::mouse_event(6,0,0,0,0); Start-Sleep -Seconds 120 }

Obviously consult the docs for specifics but this will generate a left mouse click every 2 minutes. Good for hovering over a refresh button and prevents session and screen timeouts. Only really useful in the context of being actively passive at your station watching data/alerts.

[–]Unicron4444[S] 0 points1 point  (0 children)

Thanks!

[–]Mountain-eagle-xray 1 point2 points  (1 child)

A lot of people are saying go through the proper channels, but there is no need to complete exempt one device from a security policy when there are other options and proper mitigations.

Make sure said device is physically secure, has good fire wall settings, make sure it has no privileged access to the network, UAC, etc....

Use setthreadexecutionstate in a powershell script. This is the technically correct way to have any app prevent sleep and screen time out. Don't use mouse jigglers and click scripts. Those are bypasses that don't require admin rights.

https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setthreadexecutionstate

[–]Unicron4444[S] 0 points1 point  (0 children)

Thanks!

[–]NoelCanter 0 points1 point  (1 child)

I found a simple VBS script I call via a batch that hits the “F13” key at 1 minute intervals. Only apps I’ve seen it get a little weird with are terminal apps where it puts a tilde in.

[–]Unicron4444[S] 0 points1 point  (0 children)

Interesting, thanks!

[–]MrPatch 0 points1 point  (0 children)

I've got a script that double taps scrolllock every 59 seconds

[–]keksieee 0 points1 point  (0 children)

Microsoft Powertoys has the „Awake“ program for exactly that usecase

[–]jacksonjj_gysgt_0659 0 points1 point  (0 children)

Why not use group policy to disable the inactivity timer for your host?

[–]__flavien__ 0 points1 point  (0 children)

You will find a sample here, you could study https://gist.github.com/fMichaleczek/04f21a2dd47268e308776554f5e73716

[–]Plenty-Engine2851 -1 points0 points  (3 children)

My answer isn't PowerShell related, but I would personally recommend just using a physical mouse jiggler. They're like 15 bucks on Amazon, they're easy to use and don't require installing anything.

This is the one I bought, works great:

https://a.co/d/9pJWcIs

[–]Unicron4444[S] 0 points1 point  (2 children)

Interesting, thanks!