Bill Ross
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-LocalSess ionManager 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.
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
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
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
ASKER
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\RDPConne ctionParse r.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.
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\RDPConne
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.
ASKER
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
Thanks,
Bill
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Hi Icohan,
Perfect! Do you know how to execute a PS script from TSQL?
All is working great!
Thanks,
Bill
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/
ASKER
All set. Thanks for the help!!!
ASKER
Fast help! Thanks - saved my butt.
https://social.technet.microsoft.com/Forums/windowsserver/en-US/78964658-9a04-4d2d-9506-b5516d9e4dfc/remote-desktop-reports-who-logged-in-and-logged-out-on-the-server-for-last-24-hours?forum=winserverTS
And here is a sample powershell script of doing exactly what you need https://gallery.technet.microsoft.com/Remote-Desktop-Connection-3fe225cd