I've got a PowerShell script running via Task Scheduler that's keeping my computer from locking after being idle, which is a bit frustrating. I'm wondering if there's a way to fix this issue without messing with my power settings, as they seem fine. I just need the script to let the computer time out and start the screensaver as it should. Any suggestions on how I can achieve this?
3 Answers
You might want to consider changing the registry keys instead of relying solely on your script. It can help avoid these locking issues. If you’re unsure what to update, just let me know!
So it sounds like your script is preventing the device from locking up. If that’s the case, it might be worth sharing the script. There could be something in it that’s causing it to keep the session active, but be mindful of keeping your credentials safe when you do.
The script definitely has to run with my credentials to work, but I can't share it directly. It interacts with Outlook to check emails and communicates with another program.
It’s a bit puzzling why you’re using a scheduled task for this instead of adjusting your power and screensaver settings directly. That said, if you still want to keep the script, you could use the SetThreadExecutionState function to tell Windows to keep it awake while allowing for locking. Another option is to write a simple send keys script.
I’ll take another look, but that’s not exactly what I’m trying to do. My power settings are normal; it’s just that the Powershell script makes the computer stay awake continuously.
I'm not really sure what registry keys you're talking about. Can you elaborate?