ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Server 2012 RDP: Logoff all disconnected sessions

    IT Discussion
    4
    7
    2.3k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • gjacobseG
      gjacobse
      last edited by

      In looking at my RDP server, I have a number of disconnected sessions. I know that I can log them off one at a time via Server Manager or Task Manger.

      But is there a Powershell or CMD which would do the same - for ALL disconnected session at one time.

      I'm googling - not coming up with anything right at the moment.

      1 Reply Last reply Reply Quote 2
      • black3dynamiteB
        black3dynamite
        last edited by black3dynamite

        Edit: Not sure if it will work with 2012.
        https://docs.microsoft.com/en-us/powershell/module/remotedesktop/invoke-rduserlogoff?view=win10-ps

        gjacobseG 1 Reply Last reply Reply Quote 0
        • gjacobseG
          gjacobse @black3dynamite
          last edited by

          @black3dynamite said in Server 2012 RDP: Logoff all disconnected sessions:

          Edit: Not sure if it will work with 2012.
          https://docs.microsoft.com/en-us/powershell/module/remotedesktop/invoke-rduserlogoff?view=win10-ps

          I read that and didn't understand it (at first) an hour later I think I do.... I really again don't want to do one at a time (ID)..

          black3dynamiteB 1 Reply Last reply Reply Quote 0
          • black3dynamiteB
            black3dynamite @gjacobse
            last edited by black3dynamite

            @gjacobse said in Server 2012 RDP: Logoff all disconnected sessions:

            @black3dynamite said in Server 2012 RDP: Logoff all disconnected sessions:

            Edit: Not sure if it will work with 2012.
            https://docs.microsoft.com/en-us/powershell/module/remotedesktop/invoke-rduserlogoff?view=win10-ps

            I read that and didn't understand it (at first) an hour later I think I do.... I really again don't want to do one at a time (ID)..

            You can also set up a time limit for auto logoff using group policy.
            https://4sysops.com/archives/automatically-log-off-idle-users-in-windows/

            1 Reply Last reply Reply Quote 0
            • black3dynamiteB
              black3dynamite
              last edited by

              https://4sysops.com/archives/how-to-force-a-user-logoff-remotely-with-powershell/

              1 Reply Last reply Reply Quote 1
              • dafyreD
                dafyre
                last edited by

                I have a Powershell script that I use to do this.

                The code written as is is part of a larger program PS script I wrote to manage some things.

                As it is written, it will forcibly log off anybody who is "DISCONNECTED" in the RD Server. I'd recommend running this from the Connection Broker. (Set the $connectionbroker line in the script regardless).

                https://raw.githubusercontent.com/dafyre/PoweshellScripts/master/RDS-Force-Disconnected-Logoff.ps1

                1 Reply Last reply Reply Quote 2
                • D
                  Darek Hamann
                  last edited by

                  Thanks for sharing the script, dafyre. Will give it a try, too.

                  1 Reply Last reply Reply Quote 2
                  • 1 / 1
                  • First post
                    Last post