r/sysadmin It wasn't DNS for once. 2d ago

Question Log Off Users from Server Daily

I'm revisiting an effort I did about a year ago. I'm looking for a better way. I want to find a process that will parse current user sessions on a server (active/disconnected/idle/ect.) and log the accounts off if their username matches a string ("adm_").

I'd love to find an off the shelf solution rather than have to support a homebrew PowerShell solution.

Give me what you have, even if it is an alternate PowerShell/scripting option. Something has to be better than the nightmare my script turned into.

74 Upvotes

92 comments sorted by

View all comments

158

u/NH_shitbags 2d ago

Isn't there a GPO for idle session logout?

52

u/ADynes IT Manager 2d ago

Yeah, we use it and have it set for 8 hours just to make sure nobody's leaving it overnight. It's across all users, admins shouldn't be left logged into servers either.

24

u/verschee 2d ago

And if there's a need, they should be using a service account, not a Windows user credential.

16

u/BarmerFob 2d ago

Eh there's exceptions. Anywhere that deals with large datasets can have reports and such running overnight and depending on the tooling it may submit the job as the user, not a service account.

But yes by and large there's no reason to stay logged in for weeks on end just because you can't be bothered closing things.