RDP

New ‘Get-SBRDPSession’ function added to SBTools module to get RDP sessions on one or more computers


SBTools module can be downloaded from the Microsoft Script Center Repository.

To install it, extract the .rar file, and run install-SBTools.ps1 in the folder where you extracted the .rar file.

Get-SBRDPSession:

This is a function to get RDP sessions on one or more computers. It returns object collection, each corresponding to a session. Object properties: ComputerName, UserName, SessionName, ID, and State. ID refers to RDP session ID. State refers to RDP session State

Parameters:

This function accepts the following 2 parameters:

  1. Parameter ComputerName
    If absent, function assumes localhost.
  2. Parameter State
    Filters result by one or more States (Disconnected, Connected, Active, Listen)
    Valid options are:
    Disc
    Conn
    Active
    Listen

Examples:

  • Get-SBRDPSession -ComputerName xHost15 -State Disc | FT

This example lists disconnected RDP sessions on the computer xHost16 in table format.

Sample output:

Get-SBRDPSession4

  • Get-SBRDPSession -state Active,Disc | FT

This example lists RDP sessions on the local machine, and returns those with State Active or Disc in table format.

Sample output:

Get-SBRDPSession1

  • Get-SBRDPSession xhost11,xhost12 | FT

This example lists RDP sesions on the computers xHost11 and xHost12 and outputs the result in table format.

Sample output:

Get-SBRDPSession2

  • Get-SBRDPSession (Get-Content .\computers.txt) Disc -Verbose | FT

This example reads a computer list from the file .\computers.txt and displays disconnected sessions
Get-SBRDPSession3

Advertisements