Skip to content

Instantly share code, notes, and snippets.

@automationhaus
Last active December 13, 2016 18:00
Show Gist options
  • Save automationhaus/766fa2c1941f0093243440971424cbce to your computer and use it in GitHub Desktop.
Save automationhaus/766fa2c1941f0093243440971424cbce to your computer and use it in GitHub Desktop.
Function to get the client information for the RDS session running the command - Client Name, IP Address, Session Host, Session ID...
function Get-RDSCurrentSession
{
<#
.SYNOPSIS
Provides information about the current logged in session on the session host
.DESCRIPTION
Using Cassia .NET Library gathers information on the current logged in user/client on the local session host
.EXAMPLE
PS>Get-RDSCurrentSession
.OUTPUTS
Cassia.Impl.TerminalServicesSession
.NOTES
Britt Thompson
[email protected]
.LINK
http://code.google.com/p/cassia
.LINK
https://gist.github.com/amesritter/766fa2c1941f0093243440971424cbce
#>
[OutputType("Cassia.Impl.TerminalServicesSession")]
[CmdletBinding()]
param()
try
{
Add-Type -Path "$PSScriptRoot\Bin\Cassia.dll"
$RDSClient = New-Object Cassia.TerminalServicesManager
$RDSClient.CurrentSession
} catch { Get-Catch }
}
@automationhaus
Copy link
Author

Download the Cassia .NET library here and copy it to the Bin folder in your script path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment