Link to home
Create AccountLog in
Avatar of Bill Ross
Bill RossFlag for United States of America

asked on

Need to keep track of RDS users

I need a way top keep track of Remote Desktop login/logout and disconnected sessions by userid.  I'm not familiar with PowerShell yet but I've seen some scripts that do that by exporting the  TerminalServices-LocalSessionManager events.  I'm struck though.  I would like to put into a SQL DB so we can analyze who is using the RDS.  We have 20+ RDS users.
Avatar of lcohan
lcohan
Flag of Canada image

Avatar of Bill Ross

ASKER

Hi Icohan,

I saw that but not being familiar with PS I could not get it to work.  Please help by briefly explaining the script.

.\RDPConnectionParser.ps1 -ServersToQuery Server1, Server2 -StartTime "November 1"

When I run it I get the message below so I must not understand PS enough.

.\RDPConnectionParser.ps1 : The term '.\RDPConnectionParser.ps1' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:1 char:1

Thanks for your help.

Bill
Also - Is server 1 the gateway or the RDP VM?
So you download and copy RDPConnectionParser.ps1 ON the Server where you want to get the report from;
Start Powershell on that server and run the command below where of course you will need to updated the folder name where you put it, the  server name and adjust the start date as needed:
      C:\WhateverFolder\RDPConnectionParser.ps1 -ServersToQuery YourServerNameHere -StartTime "August 1, 2018"
This will create a CSV output on the desktop you run it from.

You could aggregate all you want to do in a SSIS package to perform these steps using a parameter for the date and pull the CSV file into a SQL table.
Great help!  I got it to run.  Please explain the SSIS package concept as this would be perfect.  I can open another question if you want.

Thanks,

Bill
ASKER CERTIFIED SOLUTION
Avatar of lcohan
lcohan
Flag of Canada image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Hi Icohan,

Perfect!  Do you know how to execute a PS script from TSQL?

All is working great!

Thanks,

Bill
Here's a link to show you how to include powershell script in SSIS and how to grant the access needed for the task to not fail: https://blogs.msdn.microsoft.com/ssis/2017/01/26/run-powershell-scripts-in-ssis/
All set.  Thanks for the help!!!
Fast help!  Thanks - saved my butt.