 Rank: Advanced Member Medals:  Joined: 4/9/2010(UTC) Posts: 331
Was thanked: 2 time(s) in 2 post(s)
|
Has anyone figured out how to create a report that will allow you to see when all ScreenConnect sessions have been opened by who so you can determine how much ScreenConnect is being used by your technicians? I can go onto the server and look at all of the log files, however I need some way to take all of those and put them in a spreadsheet or some other format so I can sort based on the tech, day, length of session, etc.
|
|
|
|
 Rank: Administration Medals:  Joined: 4/9/2010(UTC) Posts: 2,061
Thanks: 1 times Was thanked: 393 time(s) in 188 post(s)
|
Here is a powershell script (also attached) that may get you there: Code:Add-Type -Path (Get-Item "..\Bin\Elsinore.ScreenConnect.Core.dll").FullName
Add-Type -Path (Get-Item "..\Bin\Elsinore.ScreenConnect.Server.dll").FullName
$serializer = New-Object System.Xml.Serialization.XmlSerializer([Elsinore.ScreenConnect.Session])
$sessionSummaries = @()
foreach ($sessionFile in Get-ChildItem("Session"))
{
$stream = [System.IO.File]::OpenRead($sessionFile.FullName)
$session = $serializer.Deserialize($stream)
$sessionSummary = New-Object Elsinore.ScreenConnect.SessionSummary
$sessionSummary.RefreshFromSession($session)
$sessionSummaries = $sessionSummaries + $sessionSummary
}
$sessionSummaries | Export-Csv -Path "report.csv"
Put it in your App_Data directory. Right click "Run with Power Shell" to run it. Then open the report.csv output in Excel. Create a Pivot Table to group by technician or anything else. The column PreviousConnectedDuration has the time connected. I had to go to "Number Format" for that column, select Time, then choose to format in hh:mm:ss format. |
ScreenConnect Team |
|
|
|
 Rank: Newbie Joined: 9/23/2011(UTC) Posts: 3 Location: Albuquerque, NM
|
Hello, I wanted to thank you for the time that you have put in on creating this report file... However I am having problems with it... It is not outputting anything. I have it in the App_Data folder, Running it in power shell. But I am not getting any output files. Any help would be great!
|
|
|
|
 Rank: Administration Medals:  Joined: 4/9/2010(UTC) Posts: 2,061
Thanks: 1 times Was thanked: 393 time(s) in 188 post(s)
|
Is there any output at all?
It will save a file called report.csv in the App_Data folder. Are you sure that file isn't there? You can modify the script if you want to output to stdout or another file. |
ScreenConnect Team |
|
|
|
 Rank: Newbie Joined: 9/23/2011(UTC) Posts: 3 Location: Albuquerque, NM
|
I am not getting any output at all.. I think i need to change the folders read/write properties... but that doesnt make since either since SC makes the log files in the folder without a problem.
|
|
|
|
 Rank: Advanced Member Medals:   Joined: 1/24/2011(UTC) Posts: 98  Location: PA Thanks: 1 times Was thanked: 2 time(s) in 2 post(s)
|
After Quite a bit of troubleshooting on this issue (thank you Jeff for showing me), I have discovered that you need to unrestrict your PS from running un-signed Scripts. Open up PowerShell and run this. Code:Set-ExecutionPolicy Unrestricted
Hit Enter and then Voila!!!! It works. @DevTeam: Is there a way you guys can sign this somehow that it works without doing this for other people? might help in the future. |
Jessy5765 Network Engineer/Web Design & Hosting
|
|
|
|
 Rank: Advanced Member Medals:   Joined: 1/24/2011(UTC) Posts: 98  Location: PA Thanks: 1 times Was thanked: 2 time(s) in 2 post(s)
|
Here is what I have received from that script, after cleaning up a few of the un-needed collums. This is pretty close to what we need. However something that is kinda confusing.
Time Connected for session, Host, session activity, Invitation type are all what we need. Two questions:
1. Whats up with those times? ( issue on our end?) 2. Why is there so many “coded” Host’s. What does that mean.
I would post a photo or something but cant seem to with this interface. lol. so here is what I am getting. Things is Bold are points of Interest as to what and why they arent working.
ConnectedDuration LastConnectedEventTime Tag Host 0:00:00 1/1/0001 12:00:00 AM AJS-NB-1.JRMComputers.Home Lj3zdVwo2dSIPkFm/fv4frnu1Qc= 0:00:00 1/1/0001 12:00:00 AM OWNER-PC.JRMComputers.Client p245CCDpFwTJs1+MX7bh2ih2ih0= 29:37.8 1/1/0001 12:00:00 AM Gary Righino jmarker 10:14.9 1/1/0001 12:00:00 AM Gary Righino jmarker |
Jessy5765 Network Engineer/Web Design & Hosting
|
|
|
|
 Rank: Administration Medals:  Joined: 4/9/2010(UTC) Posts: 2,061
Thanks: 1 times Was thanked: 393 time(s) in 188 post(s)
|
Sorry about the signing thing. I did that a long time ago to my machine. I can't believe they expect a script to be signed. Scripts are supposed to be easy. Signing defeats the purpose!
Anyway, that date is the last time it was connected, if it is still connected. 1/1/0001 is the min value, which means they aren't still connected. If they are still connected, the time between that time and the current time is not included in the ConnectedDuration. I would just wack that column if you're using it for reporting.
The weird value in the "Host" is for unattended sessions of version 2.2 or earlier (I think). It shouldn't have a value for 2.3 or 2.4 clients. You should upgrade your unattended clients. |
ScreenConnect Team |
|
|
|
 Rank: Advanced Member Medals:   Joined: 1/24/2011(UTC) Posts: 98  Location: PA Thanks: 1 times Was thanked: 2 time(s) in 2 post(s)
|
Is there a way to Wipe the Logs clean so that I can start fresh? As well to get an actuall Time connected to client Collumn? |
Jessy5765 Network Engineer/Web Design & Hosting
|
|
|
|
 Rank: Administration Medals:  Joined: 4/9/2010(UTC) Posts: 2,061
Thanks: 1 times Was thanked: 393 time(s) in 188 post(s)
|
You can just delete files from your Session directory. That'll wipe it clean. The ConnectedDuration should give you what you need for time connected to client. |
ScreenConnect Team |
|
|
|
 Rank: Advanced Member Medals:   Joined: 1/24/2011(UTC) Posts: 98  Location: PA Thanks: 1 times Was thanked: 2 time(s) in 2 post(s)
|
I meant the initial Connection time. Such as. I connected to the Client: 12/15/2011 3:45 PM, and Total ConnectedDuration: 02:13:23
That is what we were looking for. Thank you for the info on clearing out the sessions. Also is there an FAQ on how to lower the timeout on Unattended Clients? We want it to be like 5 min. |
Jessy5765 Network Engineer/Web Design & Hosting
|
|
|
|
 Rank: Member Joined: 5/14/2010(UTC) Posts: 18  Location: Chicago
|
|
|
|
|
 Rank: Newbie Joined: 2/3/2012(UTC) Posts: 8 Location: Switzerland
|
Hi I have created an other PowerShell Script, which suited my needs more that the one in this topic: Code:$stream = [System.IO.StreamWriter] "report.csv"
$da = "`""
foreach ($sessionFile in Get-ChildItem("Session"))
{
$xml = [xml](get-content $sessionFile.FullName)
$gDiff = 0.0
$hDiff = 0.0
$createdSession = "Never"
$xml.session.Event | foreach {
$tTime = $_.Time
if ($_.EventType -eq "CreatedSession") {
$createdSession = [datetime]$_.Time
}
if ($_.ProcessType -eq "Host") {
switch ($_.EventType) {
"Connected" {
$hostConnected = $tTime
}
"Disconnected" {
$tDiff = [datetime]$tTime - [datetime]$hostConnected
$hDiff = $hDiff + $tDiff.TotalMinutes
}
}
} elseif ($_.ProcessType -eq "Guest") {
switch ($_.EventType) {
"Connected" {
$guestConnected = $tTime
}
"Disconnected" {
$tDiff = [datetime]$tTime - [datetime]$guestConnected
$gDiff = $gDiff + $tDiff.TotalMinutes
}
}
}
}
if (($hDiff+$gDiff) -ne 0.0) {
$created = $createdSession.ToString("u")
$created = $created -replace ".$"
$line = $da + $created + "`";`""
$line = $line + $xml.session.host + "`";`""
$line = $line + $xml.session.InvitationType + "`";`""
$line = $line + $xml.session.Tag + "`";`""
$line = $line + $hDiff + "`";`""
$line = $line + $gDiff + $da
[array]$lines += $line
}
}
[Array]::Sort([array]$lines)
[Array]::Reverse([array]$lines)
$stream.WriteLine("`"Created`";`"User`";`"Type`";`"Code`";`"Minutes Host`";`"Minutes Guest`"")
foreach($line in $lines) {
$stream.WriteLine($line)
}
$stream.close()
It goes through all the logfiles and calculates the times the host and the guest was connected to the session. Now, I would like to call this script, using something like ActiveXObject("WScript.Shell") every time a session is ended by using the "End" button or closing a host window. Can someone help me with this? A even more preferred alternative would be a additional page with statistics like the output of my script. The page should be visible only after logging in. Edited by user Friday, February 3, 2012 7:19:46 AM(UTC)
| Reason: Not specified
|
|
|
|
 Rank: Newbie Joined: 2/3/2012(UTC) Posts: 8 Location: Switzerland
|
Hi all I have come to a "final" version. It writes an xml File and stores all the processed session files in a folder named Archive. So it doesn’t have to read through the same file twice :-) Code:if (!(test-path -path "Archiv")) { new-item "Archiv" -type directory}
$towrite = $false
[array]$logItems = @()
foreach ($sessionFile in Get-ChildItem("Session"))
{
$xml = [xml](get-content $sessionFile.FullName)
[timespan]$gDiff = 0
[timespan]$hDiff = 0
$endedSession = "Never"
$xml.session.Event | foreach {
$tTime = $_.Time
if ($_.EventType -eq "EndedSession") {
$endedSession = [datetime]$_.Time
}
if ($_.ProcessType -eq "Host") {
switch ($_.EventType) {
"Connected" {
$hostConnected = $tTime
}
"Disconnected" {
$tDiff = [datetime]$tTime - [datetime]$hostConnected
$hDiff = $hDiff + $tDiff
}
}
} elseif ($_.ProcessType -eq "Guest") {
switch ($_.EventType) {
"Connected" {
$guestConnected = $tTime
}
"Disconnected" {
$tDiff = [datetime]$tTime - [datetime]$guestConnected
$gDiff = $gDiff + $tDiff
}
}
}
}
if (($endedSession -ne "Never") -and ($hDiff+$gDiff) -ne 0.0) {
$ended = $endedSession.ToString("u")
$ended = $ended -replace ".$"
[array]$logItem = $ended
$logItem += $xml.session.host
$logItem += $xml.session.InvitationType
$logItem += $xml.session.Tag
$logItem += $([string]::Format("{0:d2}:{1:d2}:{2:d2}", $hDiff.hours, $hDiff.minutes, $hDiff.seconds))
$logItem += $([string]::Format("{0:d2}:{1:d2}:{2:d2}", $gDiff.hours, $gDiff.minutes, $gDiff.seconds))
$logItems += ,$logItem
Move-Item $sessionFile.FullName "Archiv"
$towrite = $true
}
}
if ($logitems.GetUpperBound(0) -gt 0) {
$logItems = $logItems | sort-object @{Expression={$_[0]}; Ascending=$false}
}
if (-not $towrite) {
return
}
$wsettings = New-Object system.Xml.XmlWriterSettings
$wsettings.Indent = $true
$wsettings.OmitXmlDeclaration = $false
$wsettings.NewLineOnAttributes = $true
$writer = [system.xml.XmlWriter]::Create("sessions.xml", $wsettings)
$writer.WriteStartElement("Sessions")
foreach($logItem in $logItems) {
$writer.WriteStartElement("Session")
$writer.WriteElementString("ended", $logItem[0])
$writer.WriteElementString("user", $logItem[1])
$writer.WriteElementString("type", $logItem[2])
$writer.WriteElementString("code", $logItem[3])
$writer.WriteElementString("minuteshost", $logItem[4])
$writer.WriteElementString("minutesguest", $logItem[5])
$writer.WriteEndElement()
}
$rerror = $false
$rsettings = new-object System.Xml.XmlReaderSettings
$rsettings.CloseInput = $true
$rsettings.IgnoreWhitespace = $true
try {
$reader = [System.Xml.XmlReader]::Create("archiv.xml", $settings)
}
catch {
$rerror = $true
}
if ($rerror) {
$writer.WriteEndElement()
} else {
$reader.ReadStartElement("Sessions")
while (!$reader.EOF) {
$writer.WriteNode($reader, $false)
}
$reader.Close()
}
$writer.Flush()
$writer.Close()
copy-item "sessions.xml" "archiv.xml"
In the next post, I will give a possibility to access the collected statistics from the client side. I run this script using the scheduler every 5 minutes. I would rather like to run the script every time a session is "Disconnected", but I didn't figured out how to achieve this. If anybody can help me in this, you're welcome :-) Edited by user Wednesday, February 8, 2012 3:02:29 AM(UTC)
| Reason: Not specified
|
|
|
|
 Rank: Newbie Joined: 2/3/2012(UTC) Posts: 8 Location: Switzerland
|
Hi all Ijn order to see the collected statistic data, you can add a custom page, in my case Statistic.aspx: Code:<%@ Page MasterPageFile="~/Default.master" %>
<%@ Import Namespace="System.Data" %>
<script runat="server">
sub Page_Load
dim permissionEntries = Permissions.GetEntriesForUser()
Permissions.AssertPermission(new PermissionRequest(), permissionEntries, false)
if Not Page.IsPostBack then
dim mysessions=New DataSet
mysessions.ReadXml(MapPath("App_Data\\sessions.xml"))
sessions.DataSource=mysessions
sessions.DataBind()
end if
end sub
</script>
<asp:Content runat="server" ContentPlaceHolderID="Main">
<asp:Repeater id="sessions" runat="server">
<HeaderTemplate>
<table border="1" width="100%" id="Statistics">
<thead>
<tr>
<th>Ended</th>
<th>User</th>
<th>Type</th>
<th>Code</th>
<th>Minutes Host</th>
<th>Minutes Guest</th>
</tr>
</thead>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%#Container.DataItem("ended")%></td>
<td><%#Container.DataItem("user")%></td>
<td><%#Container.DataItem("type")%></td>
<td><%#Container.DataItem("code")%></td>
<td><%#Container.DataItem("minuteshost")%></td>
<td><%#Container.DataItem("minutesguest")%></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
<script type="text/javascript" language="javascript" src="/js/jquery.js"></script>
<script type="text/javascript" language="javascript" src="/js/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
var oTable = $('#Statistics').dataTable({
"iDisplayLength": 25 });
oTable.fnSort( [ [0,'desc'] ] );
} );
</script>
</asp:Content>
Please note last last few <script> lines. I have added the code from http://datatables.net/. This enables the user to search and sort the statistic table. You can add this Page to web.config: Code: <urlMappings enabled="true">
<add url="~/Guest" mappedUrl="~/Guest.aspx" />
<add url="~/Host" mappedUrl="~/Host.aspx" />
<add url="~/Statistik" mappedUrl="~/Statistic.aspx" />
<add url="~/Administration" mappedUrl="~/Administration.aspx" />
<add url="~/Login" mappedUrl="~/Login.aspx" />
</urlMappings>
and Default.master: Code:
if (this.Page.User.Identity.IsAuthenticated)
{
linkContainerControls.Add(new HyperLink() { NavigateUrl = ServerConstants.GuestPageUrl, Text = Resources.Default.LinkPanel_GuestLinkText });
linkContainerControls.Add(new HyperLink() { NavigateUrl = ServerConstants.HostPageUrl, Text = Resources.Default.LinkPanel_HostLinkText });
// Start Anpassung JTH
linkContainerControls.Add(new HyperLink() { NavigateUrl = "/Statistik", Text = "Statistik" });
// End Anpassung JTH
If you don't want to have the navigation jump around, you have to add some lines to the resx file: Code: <data name="LinkPanel.HelpLink.Host.aspx" xml:space="preserve">
<value>http://help.screenconnect.com/</value>
</data>
<data name="LinkPanel.HelpLink.Statistic.aspx" xml:space="preserve">
<value>http://help.screenconnect.com/</value>
</data>
|
|
|
|
 Rank: Administration Medals:  Joined: 4/9/2010(UTC) Posts: 2,061
Thanks: 1 times Was thanked: 393 time(s) in 188 post(s)
|
|
ScreenConnect Team |
|
|
|
 Rank: Newbie Joined: 2/22/2012(UTC) Posts: 4
|
This is great. I am looking for a little more and I am sure you can help. I like the statistic page and I am looking to add a few features to this.
1) A drop down menu for filtering a single user. 2) a calendar to filter specific from and to dates. 3) this page only to show when an administrator logs in.
|
|
|
|
 Rank: Newbie Joined: 2/3/2012(UTC) Posts: 8 Location: Switzerland
|
Hi bwidlund
Thake a look at datatable.net, which I have included above. You can do all what you want with this.
Kind Regards Juerg
|
|
|
|
 Rank: Advanced Member Medals:   Joined: 1/24/2011(UTC) Posts: 98  Location: PA Thanks: 1 times Was thanked: 2 time(s) in 2 post(s)
|
I have everything in place and doublechecked it all. I copied everything from all the files. However I just get the Runtime Error page. Unfortunatly I use Host headers so I cant browse using localhost to see what the error is. And when i try to enter the show errors code in the web.config it locks up the Screenconnect services and stops them.
Help Please! |
Jessy5765 Network Engineer/Web Design & Hosting
|
|
|
|
 Rank: Advanced Member Medals:   Joined: 12/10/2011(UTC) Posts: 132
Thanks: 4 times Was thanked: 6 time(s) in 6 post(s)
|
Did your powershell script run ok? If I would try to access the statistics page before I ran the PS script I would get the same error. Make sure to run it from the App_Data folder and it should create an Archive folder, archive.xml and sessions.xml.
|
|
|
|
 Rank: Advanced Member Joined: 12/15/2011(UTC) Posts: 33 Location: Mid Wales
|
jthoeny wrote:Hi all I have come to a "final" version. It writes an xml File and stores all the processed session files in a folder named Archive. So it doesn’t have to read through the same file twice :-) Code:if (!(test-path -path "Archiv")) { new-item "Archiv" -type directory}
$towrite = $false
[array]$logItems = @()
foreach ($sessionFile in Get-ChildItem("Session"))
{
$xml = [xml](get-content $sessionFile.FullName)
[timespan]$gDiff = 0
[timespan]$hDiff = 0
$endedSession = "Never"
$xml.session.Event | foreach {
$tTime = $_.Time
if ($_.EventType -eq "EndedSession") {
$endedSession = [datetime]$_.Time
}
if ($_.ProcessType -eq "Host") {
switch ($_.EventType) {
"Connected" {
$hostConnected = $tTime
}
"Disconnected" {
$tDiff = [datetime]$tTime - [datetime]$hostConnected
$hDiff = $hDiff + $tDiff
}
}
} elseif ($_.ProcessType -eq "Guest") {
switch ($_.EventType) {
"Connected" {
$guestConnected = $tTime
}
"Disconnected" {
$tDiff = [datetime]$tTime - [datetime]$guestConnected
$gDiff = $gDiff + $tDiff
}
}
}
}
if (($endedSession -ne "Never") -and ($hDiff+$gDiff) -ne 0.0) {
$ended = $endedSession.ToString("u")
$ended = $ended -replace ".$"
[array]$logItem = $ended
$logItem += $xml.session.host
$logItem += $xml.session.InvitationType
$logItem += $xml.session.Tag
$logItem += $([string]::Format("{0:d2}:{1:d2}:{2:d2}", $hDiff.hours, $hDiff.minutes, $hDiff.seconds))
$logItem += $([string]::Format("{0:d2}:{1:d2}:{2:d2}", $gDiff.hours, $gDiff.minutes, $gDiff.seconds))
$logItems += ,$logItem
Move-Item $sessionFile.FullName "Archiv"
$towrite = $true
}
}
if ($logitems.GetUpperBound(0) -gt 0) {
$logItems = $logItems | sort-object @{Expression={$_[0]}; Ascending=$false}
}
if (-not $towrite) {
return
}
$wsettings = New-Object system.Xml.XmlWriterSettings
$wsettings.Indent = $true
$wsettings.OmitXmlDeclaration = $false
$wsettings.NewLineOnAttributes = $true
$writer = [system.xml.XmlWriter]::Create("sessions.xml", $wsettings)
$writer.WriteStartElement("Sessions")
foreach($logItem in $logItems) {
$writer.WriteStartElement("Session")
$writer.WriteElementString("ended", $logItem[0])
$writer.WriteElementString("user", $logItem[1])
$writer.WriteElementString("type", $logItem[2])
$writer.WriteElementString("code", $logItem[3])
$writer.WriteElementString("minuteshost", $logItem[4])
$writer.WriteElementString("minutesguest", $logItem[5])
$writer.WriteEndElement()
}
$rerror = $false
$rsettings = new-object System.Xml.XmlReaderSettings
$rsettings.CloseInput = $true
$rsettings.IgnoreWhitespace = $true
try {
$reader = [System.Xml.XmlReader]::Create("archiv.xml", $settings)
}
catch {
$rerror = $true
}
if ($rerror) {
$writer.WriteEndElement()
} else {
$reader.ReadStartElement("Sessions")
while (!$reader.EOF) {
$writer.WriteNode($reader, $false)
}
$reader.Close()
}
$writer.Flush()
$writer.Close()
copy-item "sessions.xml" "archiv.xml"
Hi, I've got the simple script working and giving me a csv file but would like to use the full script to give better resaults but i'm getting an error and no output file. It does Archieve some files Error:- Copy-Item : Cannot find path 'C:\Program Files (x86)\ScreenConnect\App_Data\sessions.xml' because it does not exist. At C:\Program Files (x86)\ScreenConnect\App_Data\Full.ps1:109 char:10 + copy-item <<<< "sessions.xml" "archiv.xml" + CategoryInfo : ObjectNotFound: (C:\Program File...ta\sessions.xml:String) [Copy-Item], ItemNotFoundExce ption + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.CopyItemCommand Hope you can help. Also would be nice to see a sessions log option with in screenconnect instead of running scripts :) *EDIT I ran it for a 2nd time don't get an errors but still no output file and the files aren't being archieved. Edited by user Wednesday, April 11, 2012 9:26:21 AM(UTC)
| Reason: Not specified
|
|
|
|
 Rank: Advanced Member Medals:   Joined: 1/24/2011(UTC) Posts: 98  Location: PA Thanks: 1 times Was thanked: 2 time(s) in 2 post(s)
|
Yeah I am getting this too, it seems that cobash found out that if you dont have the "disconnected" event in your log files. It will not work. I do not know why this happens. |
Jessy5765 Network Engineer/Web Design & Hosting
|
|
|
|
 Rank: Advanced Member Joined: 12/15/2011(UTC) Posts: 33 Location: Mid Wales
|
jessy5765 wrote:Yeah I am getting this too, it seems that cobash found out that if you dont have the "disconnected" event in your log files. It will not work. I do not know why this happens. OK thanks for the info. Will run the simple one and try and get info from it. (hmmmm might see if my PHD of a brother knows PowerShell programming :))
|
|
|
|
 Rank: Newbie Joined: 4/27/2012(UTC) Posts: 1
|
After running the first script, I get a time format like this for sessions:
LastConnectedEventTime 1/1/0001 12:00:00 AM
What's wrong? Thanks
|
|
|
|
 Rank: Advanced Member Joined: 12/15/2011(UTC) Posts: 33 Location: Mid Wales
|
If anyone is interested i have a windows app/program in development that might do a better job than what the basic script does i.e. give connection duration, start stop dates times, Tag names. Archieve files that have been processed. Will post some Beta's up when testing. Might be something the screenconnect team might intergrate at a later stage :) hint hint :) Edited by user Monday, April 30, 2012 7:39:19 AM(UTC)
| Reason: Not specified
|
|
|
|
 Rank: Advanced Member Medals:   Joined: 1/24/2011(UTC) Posts: 98  Location: PA Thanks: 1 times Was thanked: 2 time(s) in 2 post(s)
|
kerwin wrote:After running the first script, I get a time format like this for sessions:
LastConnectedEventTime 1/1/0001 12:00:00 AM
What's wrong? Thanks The reason you are getting this is probably the same reason i did. Are you using unattended sessions - if so are they up to date? Older client versions do not pull the data correctly. Try updating everything to the latest 2.4 versions and try again. :) |
Jessy5765 Network Engineer/Web Design & Hosting
|
|
|
|
 Rank: Advanced Member Medals:   Joined: 1/24/2011(UTC) Posts: 98  Location: PA Thanks: 1 times Was thanked: 2 time(s) in 2 post(s)
|
neilpcq wrote:If anyone is interested i have a windows app/program in development that might do a better job than what the basic script does i.e. give connection duration, start stop dates times, Tag names. Archieve files that have been processed.
Will post some Beta's up when testing. Might be something the screenconnect team might intergrate at a later stage :) hint hint :) .... fortunately SC's newest version 2.5 will have this built in and include back-end video monitoring of whats going on. So kinda at this point I would say SC has heard us yet again and is giving us what we want. :) Feel free to build it though. :) |
Jessy5765 Network Engineer/Web Design & Hosting
|
|
|
|
 Rank: Advanced Member Joined: 12/15/2011(UTC) Posts: 33 Location: Mid Wales
|
jessy5765 wrote:neilpcq wrote:If anyone is interested i have a windows app/program in development that might do a better job than what the basic script does i.e. give connection duration, start stop dates times, Tag names. Archieve files that have been processed.
Will post some Beta's up when testing. Might be something the screenconnect team might intergrate at a later stage :) hint hint :) .... fortunately SC's newest version 2.5 will have this built in and include back-end video monitoring of whats going on. So kinda at this point I would say SC has heard us yet again and is giving us what we want. :) Feel free to build it though. :) OK, beaten to it lol When is 2.5 Due?
|
|
|
|
 Rank: Newbie Joined: 2/22/2012(UTC) Posts: 4
|
Has anybody had any issues with this with version 2.4 on Windows Server 2008? I am not able to run the script completely. It will create the archive file but not the sessions nor the archiv xml files. The web page for statistic will not display anything also. Did I miss something when I upgraded from 2.3 to 2.4.
|
|
|
|
 Rank: Newbie Joined: 2/22/2012(UTC) Posts: 4
|
Now that the new version is out with the audit feature, the statistics page can not be used because of the copy of sessions to the archive file. Does anybody have a fix four this yet or will we need to use the audit feature instead. I prefer the statistics page.
|
|
|
|
 Rank: Newbie Joined: 12/4/2012(UTC) Posts: 1 Location: Mexico
|
neilpcq wrote:jthoeny wrote:Hi all I have come to a "final" version. It writes an xml File and stores all the processed session files in a folder named Archive. So it doesn’t have to read through the same file twice :-) Code:if (!(test-path -path "Archiv")) { new-item "Archiv" -type directory}
$towrite = $false
[array]$logItems = @()
foreach ($sessionFile in Get-ChildItem("Session"))
{
$xml = [xml](get-content $sessionFile.FullName)
[timespan]$gDiff = 0
[timespan]$hDiff = 0
$endedSession = "Never"
$xml.session.Event | foreach {
$tTime = $_.Time
if ($_.EventType -eq "EndedSession") {
$endedSession = [datetime]$_.Time
}
if ($_.ProcessType -eq "Host") {
switch ($_.EventType) {
"Connected" {
$hostConnected = $tTime
}
"Disconnected" {
$tDiff = [datetime]$tTime - [datetime]$hostConnected
$hDiff = $hDiff + $tDiff
}
}
} elseif ($_.ProcessType -eq "Guest") {
switch ($_.EventType) {
"Connected" {
$guestConnected = $tTime
}
"Disconnected" {
$tDiff = [datetime]$tTime - [datetime]$guestConnected
$gDiff = $gDiff + $tDiff
}
}
}
}
if (($endedSession -ne "Never") -and ($hDiff+$gDiff) -ne 0.0) {
$ended = $endedSession.ToString("u")
$ended = $ended -replace ".$"
[array]$logItem = $ended
$logItem += $xml.session.host
$logItem += $xml.session.InvitationType
$logItem += $xml.session.Tag
$logItem += $([string]::Format("{0:d2}:{1:d2}:{2:d2}", $hDiff.hours, $hDiff.minutes, $hDiff.seconds))
$logItem += $([string]::Format("{0:d2}:{1:d2}:{2:d2}", $gDiff.hours, $gDiff.minutes, $gDiff.seconds))
$logItems += ,$logItem
Move-Item $sessionFile.FullName "Archiv"
$towrite = $true
}
}
if ($logitems.GetUpperBound(0) -gt 0) {
$logItems = $logItems | sort-object @{Expression={$_[0]}; Ascending=$false}
}
if (-not $towrite) {
return
}
$wsettings = New-Object system.Xml.XmlWriterSettings
$wsettings.Indent = $true
$wsettings.OmitXmlDeclaration = $false
$wsettings.NewLineOnAttributes = $true
$writer = [system.xml.XmlWriter]::Create("sessions.xml", $wsettings)
$writer.WriteStartElement("Sessions")
foreach($logItem in $logItems) {
$writer.WriteStartElement("Session")
$writer.WriteElementString("ended", $logItem[0])
$writer.WriteElementString("user", $logItem[1])
$writer.WriteElementString("type", $logItem[2])
$writer.WriteElementString("code", $logItem[3])
$writer.WriteElementString("minuteshost", $logItem[4])
$writer.WriteElementString("minutesguest", $logItem[5])
$writer.WriteEndElement()
}
$rerror = $false
$rsettings = new-object System.Xml.XmlReaderSettings
$rsettings.CloseInput = $true
$rsettings.IgnoreWhitespace = $true
try {
$reader = [System.Xml.XmlReader]::Create("archiv.xml", $settings)
}
catch {
$rerror = $true
}
if ($rerror) {
$writer.WriteEndElement()
} else {
$reader.ReadStartElement("Sessions")
while (!$reader.EOF) {
$writer.WriteNode($reader, $false)
}
$reader.Close()
}
$writer.Flush()
$writer.Close()
copy-item "sessions.xml" "archiv.xml"
Hi, I've got the simple script working and giving me a csv file but would like to use the full script to give better resaults but i'm getting an error and no output file. It does Archieve some files Error:- Copy-Item : Cannot find path 'C:\Program Files (x86)\ScreenConnect\App_Data\sessions.xml' because it does not exist. At C:\Program Files (x86)\ScreenConnect\App_Data\Full.ps1:109 char:10 + copy-item <<<< "sessions.xml" "archiv.xml" + CategoryInfo : ObjectNotFound: (C:\Program File...ta\sessions.xml:String) [Copy-Item], ItemNotFoundExce ption + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.CopyItemCommand Hope you can help. Also would be nice to see a sessions log option with in screenconnect instead of running scripts :) *EDIT I ran it for a 2nd time don't get an errors but still no output file and the files aren't being archieved. Hi, I have the same problem, the first time when I ran the scrip it throw me the same error and the second, just run but does not create any file. Im running this in a Windows 2003 R2 SP2 and the ScreenConnect 3.0.3728.4701. It creates a folder "Archiv" with copy of all Sessions but even so... I Also test deleting this folder to generate again but when I open it, there's nothing on it Does anybody know why ?? or what I'm doing wrong ?? greetings
|
|
|
|
 Rank: Newbie Joined: 5/14/2013(UTC) Posts: 1 Location: For Collins, CO
|
Was playing around with the simpler of the scripts provided by Jake, but got an error message from Powershell about a formatting issue. I had this running correctly before, so my PowerShell settings should be correct, I am running the stable 3.2 release, anyone have success running that with latest versions?
|
|
|
|
 Rank: Administration Medals:  Joined: 4/9/2010(UTC) Posts: 2,061
Thanks: 1 times Was thanked: 393 time(s) in 188 post(s)
|
Here is a new report.ps1 for 3.2+: Code:Add-Type -Path (Get-Item "..\Bin\Elsinore.ScreenConnect.Core.dll").FullName
Add-Type -Path (Get-Item "..\Bin\Elsinore.ScreenConnect.Server.dll").FullName
$serializer = New-Object System.Xml.Serialization.XmlSerializer([Elsinore.ScreenConnect.Session])
$sessionSummaries = @()
foreach ($sessionFile in Get-ChildItem("Session"))
{
$stream = [System.IO.File]::OpenRead($sessionFile.FullName)
$session = $serializer.Deserialize($stream)
$sessionSummary = $session.GetSummary()
$sessionSummaries = $sessionSummaries + $sessionSummary
}
$sessionSummaries | Export-Csv -Path "report.csv"
We changed the API a little bit. |
ScreenConnect Team |
|
|
|
 Rank: Newbie Joined: 10/23/2013(UTC) Posts: 4 Location: NC
Thanks: 1 times
|
Jake wrote:Here is a new report.ps1 for 3.2+: Code:Add-Type -Path (Get-Item "..\Bin\Elsinore.ScreenConnect.Core.dll").FullName
Add-Type -Path (Get-Item "..\Bin\Elsinore.ScreenConnect.Server.dll").FullName
$serializer = New-Object System.Xml.Serialization.XmlSerializer([Elsinore.ScreenConnect.Session])
$sessionSummaries = @()
foreach ($sessionFile in Get-ChildItem("Session"))
{
$stream = [System.IO.File]::OpenRead($sessionFile.FullName)
$session = $serializer.Deserialize($stream)
$sessionSummary = $session.GetSummary()
$sessionSummaries = $sessionSummaries + $sessionSummary
}
$sessionSummaries | Export-Csv -Path "report.csv"
We changed the API a little bit. Hi Jake, I tired to use that script on our server (Windows Server 2003 R2, Powershell 1.0) and got an error message. Apologies but I am not sure how to troubleshoot the following: PS C:\Program Files (x86)\ScreenConnect\App_Data> C:\Program Files (x86)\ScreenConnect\App_Data\report.ps1 New-Object : Exception calling ".ctor" with "1" argument(s): "There was an error reflecting type 'Elsinore.ScreenConnect.Session'." At C:\Program Files (x86)\ScreenConnect\App_Data\report.ps1:4 char:25 + $serializer = New-Object <<<< System.Xml.Serialization.XmlSerializer([Elsinore.ScreenConnect.Session]) + CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand Get-ChildItem : Cannot find path 'C:\Program Files (x86)\ScreenConnect\App_Data\Session' because it does not exist. At C:\Program Files (x86)\ScreenConnect\App_Data\report.ps1:7 char:39 + foreach ($sessionFile in Get-ChildItem <<<< ("Session")) + CategoryInfo : ObjectNotFound: (C:\Program File...pp_Data\Session:String) [Get-ChildItem], ItemNotFoundException + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand ___________________________________________________________________________________________________________________________________________________________________________________ I'm assuming the Session reference is talking about Session.db which is in the App_Data folder, would that mean I just change the "Session" reference to be "Session.db"? Any help would be great.
|
|
|
|
 Rank: Newbie Joined: 11/12/2013(UTC) Posts: 8 Location: NL
|
Originally Posted by: csrms  Jake wrote:Here is a new report.ps1 for 3.2+: Code:Add-Type -Path (Get-Item "..\Bin\Elsinore.ScreenConnect.Core.dll").FullName
Add-Type -Path (Get-Item "..\Bin\Elsinore.ScreenConnect.Server.dll").FullName
$serializer = New-Object System.Xml.Serialization.XmlSerializer([Elsinore.ScreenConnect.Session])
$sessionSummaries = @()
foreach ($sessionFile in Get-ChildItem("Session"))
{
$stream = [System.IO.File]::OpenRead($sessionFile.FullName)
$session = $serializer.Deserialize($stream)
$sessionSummary = $session.GetSummary()
$sessionSummaries = $sessionSummaries + $sessionSummary
}
$sessionSummaries | Export-Csv -Path "report.csv"
We changed the API a little bit. Hi Jake, I tired to use that script on our server (Windows Server 2003 R2, Powershell 1.0) and got an error message. Apologies but I am not sure how to troubleshoot the following: PS C:\Program Files (x86)\ScreenConnect\App_Data> C:\Program Files (x86)\ScreenConnect\App_Data\report.ps1 New-Object : Exception calling ".ctor" with "1" argument(s): "There was an error reflecting type 'Elsinore.ScreenConnect.Session'." At C:\Program Files (x86)\ScreenConnect\App_Data\report.ps1:4 char:25 + $serializer = New-Object <<<< System.Xml.Serialization.XmlSerializer([Elsinore.ScreenConnect.Session]) + CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand Get-ChildItem : Cannot find path 'C:\Program Files (x86)\ScreenConnect\App_Data\Session' because it does not exist. At C:\Program Files (x86)\ScreenConnect\App_Data\report.ps1:7 char:39 + foreach ($sessionFile in Get-ChildItem <<<< ("Session")) + CategoryInfo : ObjectNotFound: (C:\Program File...pp_Data\Session:String) [Get-ChildItem], ItemNotFoundException + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand ___________________________________________________________________________________________________________________________________________________________________________________ I'm assuming the Session reference is talking about Session.db which is in the App_Data folder, would that mean I just change the "Session" reference to be "Session.db"? Any help would be great. Hello all, I'm also getting this error. It would be really nice to just get a report with (actual) date/time, session name, session duration and host name. We could use this for billing purposes (since we Always include custumer# in the session name, this would really work well for us).. I know in a previous news letter also the question was asked what we would like in the reporting/auditing field. I think this kind of report would be what most companies need.
|
|
|
|
 Rank: Administration Medals:  Joined: 7/23/2013(UTC) Posts: 715  Location: Raleigh, NC Was thanked: 66 time(s) in 63 post(s)
|
That Powershell script was from before we started using a database for sessions. Now you can use sqlite3 on the Session.db file to get info pretty easily if you know some SQL (although session IDs show up as garbage). Calculating the session duration is rather difficult, but Jake had some SQL already written to do that: Code:DROP VIEW SessionConnectionTime1;
DROP VIEW SessionConnectionTime2;
DROP VIEW SessionConnectionTime3;
DROP VIEW SessionConnectionTime4;
DROP VIEW SessionConnectionTime5;
DROP VIEW SessionConnectionTime6;
CREATE VIEW SessionConnectionTime1 AS
SELECT a.*, b.Time AS ConnectTime, c.Time AS DisconnectTime
FROM SessionConnection a
INNER JOIN SessionConnectionEvent b ON a.SessionID = b.SessionID AND a.ConnectionID = b.ConnectionID AND b.EventType = 10
INNER JOIN SessionConnectionEvent c ON a.SessionID = c.SessionID AND a.ConnectionID = c.ConnectionID AND c.EventType = 11;
CREATE VIEW SessionConnectionTime2 AS
SELECT
a.SessionID,
a.ConnectionID,
a.ConnectTime,
a.DisconnectTime,
(SELECT MAX(DisconnectTime) FROM SessionConnectionTime1 b WHERE b.ProcessType <> a.ProcessType AND b.ConnectTime <= a.ConnectTime AND b.DisconnectTime > a.ConnectTime) MaxOtherDisconnectTime
FROM SessionConnectionTime1 a;
CREATE VIEW SessionConnectionTime3 AS
SELECT
SessionID,
ConnectionID,
ConnectTime StartTime,
(CASE WHEN DisconnectTime > MaxOtherDisconnectTime THEN MaxOtherDisconnectTime ELSE DisconnectTime END) EndTime
FROM SessionConnectionTime2
WHERE NOT MaxOtherDisconnectTime IS NULL;
CREATE VIEW SessionConnectionTime4 AS
SELECT
SessionID,
ConnectionID,
MIN(StartTime) StartTime,
EndTime
FROM SessionConnectionTime3
GROUP BY SessionID, EndTime;
drop table sct;
create table sct as select * from SessionConnectionTime4;
CREATE VIEW SessionConnectionTime5 AS
SELECT
SessionID,
ConnectionID,
strftime('%s', EndTime) EndSeconds,
strftime('%s', StartTime) StartSeconds
FROM
sct;
CREATE VIEW SessionConnectionTime6 AS
SELECT
SessionID,
SUM(EndSeconds - StartSeconds) SecondsConnected
FROM
SessionConnectionTime5
GROUP BY SessionID;
|
ScreenConnect Team |
|
|
|
 Rank: Newbie Joined: 11/12/2013(UTC) Posts: 8 Location: NL
|
Thanks Alexander, I will give that a try.
|
|
|
|
 Rank: Newbie Joined: 11/19/2015(UTC) Posts: 17  Location: CA
|
Does this SQLlite script still work with the latest versions of screenconnect? I'm trying to run it and it's giving me errors like "no such view" and "no such table".
|
|
|
|
 Rank: Administration Medals:  Joined: 7/23/2013(UTC) Posts: 715  Location: Raleigh, NC Was thanked: 66 time(s) in 63 post(s)
|
It should, I believe; it's probably just the drop view/drop table statements that are giving those errors. |
ScreenConnect Team |
|
|
|
 Rank: Newbie Joined: 11/19/2015(UTC) Posts: 17  Location: CA
|
does it write to a file or should I see results under the execute SQL statement in the section directly above the errors? I'm not seeing any results when I run this.
|
|
|
|
 Rank: Administration Medals:  Joined: 7/23/2013(UTC) Posts: 715  Location: Raleigh, NC Was thanked: 66 time(s) in 63 post(s)
|
Oh, that's probably because it doesn't display any results as-is; you should be able to look at those views/tables, though. |
ScreenConnect Team |
|
|
|
 Rank: Newbie Joined: 11/19/2015(UTC) Posts: 17  Location: CA
|
So once I hit play to execut the SQL statement, I go to browse data tab and should be able to see something?
I'm a total noob to this, i am running DB browser for SQLLite version 3.7.0.
I copied and pasted the SQL statement above into the Execute SQL tab and hit the blue Play button. Where do I go to see the results?
Thanks,
JMG
|
|
|
|
 Rank: Administration Medals:  Joined: 7/23/2013(UTC) Posts: 715  Location: Raleigh, NC Was thanked: 66 time(s) in 63 post(s)
|
Hmm, looks like you have to delete or comment out the drop view/drop table lines (like "--DROP VIEW SessionConnectionTime1;", for example), otherwise it just stops once it hits an error. Once you've done that and run it, then yeah, you can see the views/tables in the Browse Data tab, or use them in other SQL queries. |
ScreenConnect Team |
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.