This Function allows you to locally or remotely disconnect another computer's file/folder session on a machine.  There are a few options in determining whether to disconnect the session based on the minimum resources that are currently opened on the server or the amount of time that the session has been idle.  Other options are to generate a log file with any errors encountered or logging all of the sessions that were closed. Can also set Verbose and WhatIf on the Function as well. Can be run as a scheduled job as well to automate control of how long users can have an inactive session.

PowerShell
Edit|Remove
. .\Disconnect-FileSession.ps1