We have a user that cannot seem to close his/her QuickBooks session at the end of the day.
So I created the following PowerShell script to logout the specified user:
$sessions= query user username
$sessionid=$sessions.Substring(39,6).Trim() |select-object -index 1
Invoke-RDUserLogoff -HostServer "localhost" -UnifiedSessionID $sessionid -Force
Change username to be the username of the target user you want logged off then set a schedule task when it should happen.
References:
https://www.nextofwindows.com/windows-tip-how-to-remotely-logoff-users-via-command-line-tools
https://serverfault.com/questions/347723/how-to-look-for-a-user-terminal-session-in-powershell