Manage 2012 R2 RDSH Pool Sessions without Connection Broker

rdpremote desktopremote-desktop-serviceswindows-server-2012-r2

I'm trying to manage user sessions across 10+ 2012 R2 RDSH Hosts inside a vWorkspace 8.6.1 Farm without a 2012 R2 Connection Broker Role.

I am concerned that adding the Connection Broker, creating a pool, and adding servers to it will interfere with the policy settings and load balancing rules setup in vWorkspace (two drivers, one car). And the vWorkspace controls are not intuitive enough to deploy to tier 1 support and somewhat clunky.

This wasn't a problem in 2008 and previous versions but now Microsoft has replaced all the previous standalone tools and seemingly forced their Server Manager / Connection Manager role setup.

Looking for a powershell script (or other) option to manage user logoffs, shadowing sessions, etc (across the pool) that doesn't reference a connection broker. Most scripts / tools for powershell now reference a Collection: TechNet Get-RDUserSession

Get-RDUserSession -ConnectionBroker "rdcb.contoso.com"

Best Answer

You can actually use Get-RDUserSession for this task. Just refer to the collectionname, not to the connectionbroker

Get-RDUserSession -collectionname "Mycollection" | ft Username, UnifiedSessionId

this will get you the session IDs of all RDP connections

then you can shadow those with this command (in this example, sessionid "3" is shadowed)

Mstsc /shadow:3 /control

To make your life easier you could use a function that looks for the UserName.

function ShadowSession([string]$UserName, [string]$CollectionName)
{
    $SessionID = Get-RDUserSession -collectionname $CollectionName |
        select UnifiedSessionId | ? {$_.Username -eq $UserName}
    mstsc /shadow:$SessionID /control
}

so you command would be

ShadowSession -UserName "User01" -CollectionName "MyCollection"

if you have only one RDS collection use this

function ShadowSession([string]$UserName)
{
    $SessionID = Get-RDUserSession -collectionname "MyCollection" |
        select UnifiedSessionId | ? {$_.Username -eq $UserName}
    mstsc /shadow:$SessionID /control
}

then you don't have to refer to the collectionname, only the username

ShadowSession -UserName "User01"

You can even go further and add switches to your function

then you could use this function for everything you want. shadowing, logging off, etc.