Skip to content

Yevrag35/ConnectedUsers

Repository files navigation

ConnectedUsers

version downloads

ConnectedUsers is a PowerShell module that provides cmdlets to query and disconnect local and remote user sessions.

Cmdlets

  • Get-ConnectedUser (aliases: Get-QUser, gcu): Retrieves information about user sessions.
  • Remove-ConnectedUser (aliases: Remove-QUser, rcu): Disconnects a specified user session.

Installation

You can install the ConnectedUsers module from the PowerShell Gallery: Link to the Gallery Page

Usage

After installation, import the module:

Import-Module ConnectedUsers

Retrieving User Sessions

To retrieve all user sessions on the local machine:

Get-ConnectedUser

To retrieve sessions on remote machines:

Get-ConnectedUser -ComputerName "RemotePC1", "RemotePC2"

Logoff a User Session

To logoff a user session by specifying the Session ID:

Remove-ConnectedUser 1

To disconnect a user session on a remote machine:

Remove-ConnectedUser -SessionId 2 -ComputerName "RemotePC"

To logoff a specific user from multiple machines:

$userName = "thisguy"
Get-ConnectedUser -ComputerName "RemotePC1", "RemoteServer1" | Where-Object { $_.UserName -eq $thisGuy } | Remove-ConnectedUser

About

A set of PowerShell cmdlets to query and disconnect local and remote Windows logon sessions.

Resources

License

Stars

Watchers

Forks