What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Is there any way to see what users are logged into PRTG?

Votes:

0

I have a lot of users in my PRTG and I'd like to see who's logged in and when we reach peaks. Is that possible?

active prtg users

Created on Sep 16, 2016 10:36:55 AM by  Stephan Linke [Paessler Support]



66 Replies

Accepted Answer

Votes:

1

This article applies to PRTG Network Monitor 16 or later

Introduction

PRTG can't show the currently logged in users, but it's possible with the script below.
Please save it as PRTG-GetLoggedInUsers.ps1 When you just execute it, it will look like this:

Logged in users in PRTG Logged in Users within PRTG

The list will allow you to add filter criteria for each column and show all configured users. You can also use it as a PRTG sensor, then it will look something like this:

The script configured as a sensor in PRTG The script configured as a sensor in PRTG

Installation

  1. Save the script as PRTG-GetLoggedInUsers.ps1 to
    %programfiles(x86)%\PRTG Network Monitor\Custom Sensors\EXE
  2. Modify the script's parameters according to the table in the Parameters section of this post
  3. The script uses Invoke-WebRequest which may lead to PowerShell complaining about the IE not being started yet. The following registry setting will ignore that. Thanks to Daniel Schickmair:

    [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Internet Explorer\Main]
    "DisableFirstRunCustomize"=dword:00000001
  4. Create a new EXE/Script Sensor on the Local Probe device
  5. Select PRTG-GetLoggedInUsers.ps1 from the EXE/Script dropdown menu
  6. Hit Continue The sensor should go green with the next scan, given that all parameters are configured correctly. Otherwise, you'll receive an error stating it could not connect to PRTGs webinterface.

Parameters

Parameter NameDescriptionExample
$prtgProtocolThe protocol used by your PRTG.Use either http or https.
$prtgPortThe port your webinterface uses80
$prtgHostThe FQDN of your PRTG webinterfaceprtg.acme.com
$prtgUserThe user accessing the APIprtgadmin
$prtgPasshashThe passhash of the above user12345678

Notes

  • Please don't configure intervals lower than five minutes as it will lead to performance issues otherwise.

Script

#requires -version 4.0
# ___ ___ _____ ___
#| _ \ _ \_   _/ __|
#|  _/   / | || (_ |
#|_| |_|_\ |_| \___|
# Active PRTG Users
# ================================
# This script will show you the PRTG users that are currently logged in or have logged in today. 
# NOTE: Please don't configure intervals lower than five minutes as it will lead to performance issues otherwise.
#
# Version History
# ----------------------------
# 1.2      Updated to new logging paths of PRTG 18.3.43. Invalid SSL certificates will also work properly now.
# 1.1      Switched to reading users via webinterface. 
# 1.05     Changed search method, now takes 0.14s for every user instead of ~3s in large log files
#          Better debugging output
# 1.01     Updated comments and documentation
# 1.0      initial release
# # # # # # # # # # # # # # # # # # # # # # # # # #
param( 
       [string]$prtgProtocol = "http",
          [int]$prtgPort     = 80, 
       [string]$prtgHost     = "your.prtg.com", 
       [string]$prtgUser     = "prtgadmin", 
       [string]$prtgPasshash = "12345678"
)


function Console-ShowMessage([string]$type,[string]$message){
        Write-Host ("[{0}] " -f (Get-Date)) -NoNewline;
        switch ($type){
            "success"       { Write-Host "    success    "  -BackgroundColor Green      -ForegroundColor White -NoNewline; }
            "information"   { Write-Host "  information  "  -BackgroundColor DarkCyan   -ForegroundColor White -NoNewline; }
            "warning"       { Write-Host "    warning    "  -BackgroundColor DarkYellow -ForegroundColor White -NoNewline; }
            "error"         { Write-Host "     error     "  -BackgroundColor DarkRed    -ForegroundColor White -NoNewline; }
            default         { Write-Host "     notes     "  -BackgroundColor DarkGray   -ForegroundColor White -NoNewline; }
        }
        Write-Host (" {0}{1}" -f $message,$Global:blank) 
}

#region configuration
$progressPreference = 'silentlyContinue'

# ignore invalid ssl certs
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
    public bool CheckValidationResult(
        ServicePoint srvPoint, X509Certificate certificate,
        WebRequest request, int certificateProblem) {
        return true;
    }
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy


# The list of the users
$Users = New-Object System.Collections.ArrayList;

# We'll need the current date to get the correct log file
[string] $currentDate     = (date -format "yyyyMMdd");

# Extract the correct data path from the registry
[string] $LogFilePath     = ((Get-ItemProperty -Path "hklm:SOFTWARE\Wow6432Node\Paessler\PRTG Network Monitor\Server\Core" -Name "Datapath").DataPath) + "Logs\webserver\WebServer.log"

# Get the content of the log file 
[string[]]$LogFileContent = (Get-Content $LogFilePath);

#endregion

function This-GetLogLines([string]$searchstring){
    
    $Lines = ($LogFileContent -match $searchstring)

    if($Lines) { return $Lines;  }
    else       { return $false; }

}

# This will retrieve all active users from the configuration file and compare them to the webserver log
function This-GetUsers(){

    begin { 
        Console-ShowMessage -type information -message "Using $($LogFilePath)"
        Console-ShowMessage -type information -message "Log is $($LogFileContent.Count) lines long";
        Console-ShowMessage -type information -message "Loading Users..."
    }

    process {
        # uncomment the following line if you've forced TLS 1.2 in PRTGs webinterface
        # [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

        # Receive the current PRTG user list   
        try   {$Object = (Invoke-Webrequest -Uri ([string]::Format("{0}://{1}:{2}/config_report_users.htm?username={3}&passhash={4}", $prtgProtocol,$prtgHost, $prtgPort,$prtgUser, $prtgPasshash)) -SessionVariable PRTG)}
        catch { 
            Console-ShowMessage -type error -message "Could not access PRTG webinterface. Please check URL and credentials!";  
            Write-Host "0:Could not access PRTG webinterface. Please check URL and credentials!"    
            #exit 1;  
        }
        
        Foreach($Link in $Object.Links){
            if($Link.OuterHTML -match "edituser.htm" -and [int]$Link.Id)
            { $User = New-Object PSObject –Property @{UserName = $Link.InnerHtml; UserID = $Link.Id}; $Users.Add($User) | Out-Null }
        }
     
           # Get a list of all active users in PRTG - others can't login anyway. 
           Console-ShowMessage -type success -message "Found $($Users.Count) users"; 

           # For every active user in the list ...
           $loggedInUsers = Foreach($User in $Users){

              Console-ShowMessage information "Checking $($User.UserName)"
              #...get the last entry of the user
              $Result = (This-GetLogLines -searchstring "user$($User.UserId)"); 
          
              if($Result)
              { Console-ShowMessage information "$($Result.Length) log entries for this user." -nonewline }
          
              # If the last entry of the user matches logout, he isn't logged in
              $LastEntry = $Result[$Result.Length-1]

              if($LastEntry -match "logout")
              { $LoggedIn = "No" }      

              # If any of the above is not the case, he's logged in. Fill the variables accordingly
              elseif($LastEntry)
              { $LoggedIn = "Yes" }
                        
              if(!($Result)) 
              {   $LoggedIn = "No login today"; $Date = "-"; $Time = "-"; $IP = "-"; }


              $LastEntry = $Result[$Result.Length-1] -split " "
              
              if($LastEntry){ 
                  # fill the variables  with the items from the log line
                  $Date = $LastEntry[1];
                  $Time = $LastEntry[2];
                  $IP   = $LastEntry[3];
              }

              [pscustomobject]@{
                "Last Seen"   = $Time;
                "IP Address"  = $IP
                "User"        = $User.UserName;
                "Logged in"   = $LoggedIn;
              }
           }

        
        # We need this for the PRTG output. It will put all logged in users into an array so we can display them in the sensor message
        $Userlist = @(); 
        $ActiveUsers = ($loggedInUsers | Where-Object -FilterScript {$_.'Logged in' -match "Yes"});
        foreach($ActiveUser in $ActiveUsers){ $Userlist += $ActiveUser.User }
    
    }

    End {
      # If we have the $prtg parameter set, the script will output data using the EXE/Script format (<value>:<message>); 
      if($Userlist.Count -eq 0)    { $UserString = "" }
      else                         { $UserString = "(" + ($Userlist -join ", ") + ")" }
      
      Write-Host ([string]::Format("{0}:{0} user(s) currently logged in {1}",$Userlist.Count,$UserString));
      $loggedInUsers | Out-GridView -Title "[PRTG] Active Users";     
      
    }    
}

This-GetUsers

Created on Sep 16, 2016 10:54:08 AM by  Stephan Linke [Paessler Support]

Last change on Jan 7, 2020 11:09:07 AM by  Maike Guba [Paessler Support] (2,404) 2 1



Votes:

0

This is great! Something we have been looking for for some time. Thanks!

BUT... (there's always a BUT, isn't there?!) :) We were able to get the PS script running and displaying the number of logged in users via powershell, but the data does not translate through to the sensor. I.e. we get 14 users logged in... and the 14 names of the users when running the script, but when we run it as a sensor, it connects, shows green/OK, and tells us there are 0 Users logged in.

Any help would be appreciated! Todd

Created on Sep 7, 2017 7:20:33 PM



Votes:

0

Hi Todd,

Did you check if the "Use security context of parent device" option is enabled in the sensor's security settings? If not, make sure that you've entered administrative credentials in the device settings.

It should work then...let me know if the above did the trick :)


Kind regards,
Stephan Linke, Tech Support Team

Created on Sep 8, 2017 10:14:34 AM by  Stephan Linke [Paessler Support]



Votes:

0

Did everything like described above and get

Antwort nicht wohlgeformt: "(Missing or invalid array index expression. At C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXE\PRTG-GetLogg dInUsers.ps1:148 char:46 + $loggedInUsers | Out-GridView -Title "[ <<<< PRTG] Active Users"; + CategoryInfo : ParserError: ([:String) [], ParseException + FullyQualifiedErrorId : MissingArrayIndexExpression )" (Code: PE132)

Version: PRTG Network Monitor 17.3.33.2830 x64

Right now this is just a test on my local client system. Done so before going life on our servers.

Thank you in advance Greets

Created on Sep 13, 2017 10:59:48 AM

Last change on Sep 13, 2017 6:24:12 PM by  Stephan Linke [Paessler Support]



Votes:

0

Could you post the complete script including credentials? I won't publish it, I just want to make sure everything is configured properly and rule out copy and paste errors.


Kind regards,
Stephan Linke, Tech Support Team

Created on Sep 13, 2017 6:27:25 PM by  Stephan Linke [Paessler Support]



Votes:

0

Meanwhile I found out that my Powershell Version was too old. I updated and now I'm getting the same result like Todd.

0 users are logged in.

Thank you in advance for any advice

Created on Sep 14, 2017 7:04:59 AM



Votes:

0

The main problem here is that the password was entered instead of the users' passhash. You can find it under <your-prtg>/myaccount.htm?tabid=1 via the button [Passhash anzeigen]. Should work then.


Kind regards,
Stephan Linke, Tech Support Team

Created on Sep 14, 2017 8:31:58 AM by  Stephan Linke [Paessler Support]



Votes:

0

Thanks for the hint in regard of using the 'passhash'. With that and using Powershell v4 I receive the same errors (at line 148 char 46) as cyberclaus62 above...

Are you sure that the posted script does not contain any formatting errors (because PowerShell ISE shows some 'missing terminators' and 'missing closings')?

Thank you in advance for your advice!

Created on Sep 14, 2017 11:28:23 AM



Votes:

0

Hi,

did what you said but ... no success. The Logfile sais

[14.09.2017 14:35:10]   information   Using C:\ProgramData\Paessler\PRTG Network Monitor\Logs (Web Server)\prtg20170914.log
[14.09.2017 14:35:10]   information   Log is 5970 lines long
[14.09.2017 14:35:10]   information   Loading Users...
[14.09.2017 14:35:10]   information   https://127.0.0.1:443/config_report_users.htm?username=prtgadmin&passhash=*******
[14.09.2017 14:35:10]      error      Could not access PRTG webinterface. Please check URL and credentials!
[14.09.2017 14:35:10]     success     Found 0 users
0:0 user(s) currently logged in 

What's my mistake now? Can you please help me out?

Thanks

Greets cyberclaus62

Created on Sep 14, 2017 12:37:06 PM

Last change on Sep 14, 2017 12:47:25 PM by  Stephan Linke [Paessler Support]



Votes:

0

Just copied it 1:1 into a new ISE window and it works properly:

[14.09.2017 14:45:34]   information   Using C:\ProgramData\Paessler\PRTG Network Monitor\Logs (Web Server)\prtg20170914.log
[14.09.2017 14:45:34]   information   Log is 6284 lines long
[14.09.2017 14:45:34]   information   Loading Users...
[14.09.2017 14:45:35]     success     Found 5 users
[14.09.2017 14:45:35]   information   Checking Benutzer
[14.09.2017 14:45:35]   information   Checking dashboard
[14.09.2017 14:45:35]   information   Checking PRTG System Administrator
[14.09.2017 14:45:35]   information   3756 log entries for this user.
[14.09.2017 14:45:35]   information   Checking prtgscheduler
[14.09.2017 14:45:35]   information   Checking Stephan Linke
1:1 user(s) currently logged in (PRTG System Administrator)

Is PRTG actually listening at 127.0.0.1? Like, https://127.0.0.1:443 is showing the PRTG login mask?


Kind regards,
Stephan Linke, Tech Support Team

Created on Sep 14, 2017 12:49:18 PM by  Stephan Linke [Paessler Support]



Votes:

0

It doesn't run in my ISE neither. I use the connection string

https://127.0.0.1:443/config_report_users.htm?username=prtgadmin&passhash=1234578690

(as you can see in my output above)

But, this string in the address bar of the browser works fine.

The server runs on localhost, 127.0.0.1 and I use https on port 443. There are 3 users defined, 2 admins and one regular user.

I might miss some other thing. Do I need to install some other parts of the PRTG software; I see a scheduler in your output. Or isn't windows 7 new enough for this task? Am I missing some API or a certificate?

Kind regard back to use and many thanks for your work and patience.

Created on Sep 14, 2017 1:22:43 PM

Last change on Sep 14, 2017 2:05:00 PM by  Stephan Linke [Paessler Support]



Votes:

0

Hi Stephan, We are using Windows account credentials (with Admin privs) entered on the parent device itself (which is the main Core of the system.) I did end up finding the setting I believe you are referencing:

On the Sensor > Settings > Sensor Settings section - Security Context

-It was by default set to "Use security context of probe service"

-We have since changed it to "Use Windows credentials of parent device" unfortunately it does not seem to make any difference. I am still able to get a good result running the PowerShell script directly on the server, but "0 Users Logged In" result with the sensor itself.

We have tried deleting and re-adding the sensor several times playing with different settings each time, but to no avail.

Created on Sep 14, 2017 3:35:05 PM



Votes:

0

To All:

If you get an error message when you initially run the PowerShell script stating: "Response is not well-formed" (or "Antwort nicht wohlgeformt" in German) try copying the script text that appears on this page into a plain notepad session.

We were initially copying the script from this web page into a Notepad++ editor, then saved as a PS1 file. This seemed to be what caused in the "Response is not well-formed" error - when we closely examined the pasted copy of the script there were several syntax issues including dashes that became double-dashes "--" or other html code. I assume that is from us grabbing the text from our web browsers - the web agents render some of these characters differently when pasting into a html-capable editor. When we pasted from the web page directly into notepad, no problems! We were then able to open up the PS1 file with Notepad++ and edit successfully, it was just the initial paste operation that went sideways.

Hopefully this helps! (and if tested further could be added to the instructions for newbies like myself who before last week had ZERO powershell experience!)

Cheers,

Todd

Created on Sep 14, 2017 3:54:33 PM



Votes:

0

Hi Todd,

Interesting find - I did the same and it actually didn't work. The reason here was the encoding of the file, being set to UTF-8 without BOM. Setting it to UTF-8 made the sensor magically work.

@cyberklaus62 Does this apply to you as well?


Kind regards,
Stephan Linke, Tech Support Team

Created on Sep 15, 2017 6:28:08 AM by  Stephan Linke [Paessler Support]



Votes:

0

Hi Stephan,

thanks to you and to Todd but no matter waht I try, it doesn't work. I still get "0 users". I tried (even in several combinations)

- pasting the code using different browsers - pasting into Notepad++ and converting to UTF-8 - pasting into Notepad++ and converting to UTF-8 - pasting into ISE and saving - pasting into the old notepad and saved as UTF-8

I extended the code by the following line

$X = ([string]::Format('{0}:{1}:{2}/config_report_users.htm?username={3}&passhash={4}', $prtgProtocol,$prtgHost,$prtgPort,$prtgUser,$prtgPasshash)); Console-ShowMessage -type information -message $X;

directly under the line " # Receive the current PRTG user list"

and can see that the connection string is correct.

But at the end I see

Could not access PRTG webinterface. Please check URL and credentials! and then 0:0 user(s) currently logged in

Kind regards cyberclaus62

Created on Sep 15, 2017 7:03:05 AM



Votes:

0

Any HTTPS related errors here?


Kind regards,
Stephan Linke, Tech Support Team

Created on Sep 15, 2017 11:23:38 AM by  Stephan Linke [Paessler Support]



Votes:

0

Seem so. Setting the web server back to http-protocoll and port 80 (or in my case 81) everything works fine.

But what's the problem and how to solve it? What can we try? What can we do?

Kind regards

cyberclaus62

Created on Sep 15, 2017 12:05:19 PM



Votes:

0

Try adding this before the #region configuration:

add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
    public bool CheckValidationResult(
        ServicePoint srvPoint, X509Certificate certificate,
        WebRequest request, int certificateProblem) {
        return true;
    }
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy

May or may not work. PowerShell is rather picky when it comes to SSL certificates. Only way around would be to use a signed (valid) SSL certificate instead :)


Kind regards,
Stephan Linke, Tech Support Team

Created on Sep 15, 2017 12:12:32 PM by  Stephan Linke [Paessler Support]



Votes:

0

WORKS!!!!

Great, I'm happy.

At this point I don't want to forget to say a big Thank You to Stephan from the Support Team for the excellent support, fast replays and finally the solution.

Kind regards and a great time

cyperclaus62

Created on Sep 18, 2017 5:39:15 AM



Votes:

0

Following Todd's advice (copy to old Notepad and edit and set to UTF-8 in Notepad++) solved my issue :) I like to add that we are also using a HTTPS connection with a signed (valid) SSL certificate to access PRTG and there is no issue either.

Many thanks to Todd and Stephan and best regards, Frank

Created on Sep 19, 2017 12:30:40 PM



Votes:

0

Unfortunately my praise might have been too early for the sensor only works for 2-3 intervals (I have set 15 minutes) and after that shows "0:0 users" again. The sensor output to disk shows an error to access the PRTG webinterface, but when I log in to the core server (with the Windows user of the parent device) the PS script works and also the URL works...

Could you guide me to troubleshoot this any further?

Created on Sep 26, 2017 9:04:30 AM



Votes:

0

Frank,

Could you post the exact error?


Kind regards,
Stephan Linke, Tech Support Team

Created on Sep 26, 2017 10:04:11 AM by  Stephan Linke [Paessler Support]



Votes:

0

(Sorry for the delay; I was ill.) Hi Stephan,

it's the same error as has been posted by cyberclaus62 previously:

[10.10.2017 14:00:26]   information   Using D:\Paessler\PRTG Network Monitor\Logs (Web Server)\prtg20171010.log
[10.10.2017 14:00:26]   information   Log is 11715 lines long
[10.10.2017 14:00:26]   information   Loading Users...
[10.10.2017 14:00:26]      error      Could not access PRTG webinterface. Please check URL and credentials!
0:Could not access PRTG webinterface. Please check URL and credentials!
[10.10.2017 14:00:26]     success     Found 0 users
0:0 user(s) currently logged in 

Although the message seems clear, when I access the url with correct credentials from my computer or from the core server itself (just after this error occurred), then the page is shown without error in the browser...

Any thoughts? Thanks and regards, Frank

Created on Oct 10, 2017 12:17:05 PM

Last change on Oct 10, 2017 12:28:13 PM by  Stephan Linke [Paessler Support]



Votes:

0

Hi Frank,

Please modify the script and add the following beneath the Console-ShowMessage:

Console-ShowMessage -type error -message "Could not access PRTG webinterface. Please check URL and credentials!";
Write-Host $_.Exception.Message

What's the Exception message?


Kind regards,
Stephan Linke, Tech Support Team

Created on Oct 10, 2017 12:30:06 PM by  Stephan Linke [Paessler Support]



Votes:

0

Hi Stephan, thanks for your feedback. This is the detailed message:

The response content cannot be parsed because the Internet Explorer engine is not available, or Internet Explorer's first-launch configuration is not complete. Specify the UseBasicParsing parameter and try again.

I have checked that when I log in (with the Windows user account of the PRTG parent device) IE starts normally on the PRTG core server.

Would I have to configure this 'UseBasicParsing' parameter? If yes, how?

Best regards, Frank

Created on Oct 12, 2017 12:08:47 PM



Votes:

0

Hi Frank,

While this would be the common workaround, I'm unsure if it will work. I'll do some testing tomorrow.


Kind regards,
Stephan Linke, Tech Support Team

Created on Oct 12, 2017 1:45:51 PM by  Stephan Linke [Paessler Support]



Votes:

0

Hi Frank,

-UseBasicParsing will work, but you'll not see any usernames in the list, so it's of little use. Is the sensor configured to actually use the account of the parent device in the security context setting? When launching IE with this very user, you should see the following:

title

Did you click OK in this dialogue? If so, the script should work when executed while being logged in as this user. Let me know if it did the trick :)


Kind regards,
Stephan Linke, Tech Support Team

Created on Oct 13, 2017 12:49:13 PM by  Stephan Linke [Paessler Support]



Votes:

0

[It seems as if my last reply was not saved...] Hi Stephan, after two resets of IE I must report that it is still not working. The sensor shows '0' users and ONLY seems to be working when the Windows user (of the parent device) is logged on to the PRTG server. As soon as the Windows user is logged out of the server the sensor logs the previously mentioned error message at the next interval. (Additionally when the logged in users are displayed the 'prtgadmin' user is always listed too - but it is only used to access the API url...)

If there is an easy fix to this I appreciate your advice for it would be a cool feature. (Otherwise it seems a bit too much effort for something that in my opinion should actually be included in PRTG by default anyway.)

Thanks and best regards, Frank

Created on Oct 26, 2017 8:46:14 AM



Votes:

0

API users count as "logged in", too. It's very strange and I haven't observed this behavior :( I'm out of ideas to be honest...maybe something like this will be implemented natively one day :)


Kind regards,
Stephan Linke, Tech Support Team

Created on Nov 1, 2017 9:39:04 AM by  Stephan Linke [Paessler Support]



Votes:

0

OK, let's leave it at this. Thanks anyway for your support! Best regards, Frank

Created on Nov 1, 2017 4:41:46 PM



Votes:

0

Hi Stephan,

I finally got it to work!

In the end I had to configure the (at least 'local') group policy for the PRTG probe server's IE and enable the 'Prevent running First Run wizard' policy setting under Administrative Templates >Windows Components >Internet Explorer (as opposed to many internet sources I had to enable this in the 'Computer Configuration' and not in the 'User Configuration' for my Windows 2012R2 server...).

Since the sensor is working now I would only like to learn if it would be possible to exclude the API User from the user count - otherwise it seems as if always someone was logged in...

Is there a possibility within the script? i.e. to simply define the result with "-1" or else?

Best regards, Frank

Created on Nov 8, 2017 12:29:07 PM



Votes:

0

Hi Frank,

Nice! :) The -1 would be possible by replacing the following line at the end:

Write-Host ([string]::Format("{0}:{0} user(s) currently logged in {1}",$Userlist.Count,$UserString));

with the following:

Write-Host ([string]::Format("{0}:{0} user(s) currently logged in {1}",($Userlist.Count - 1),$UserString));

Created on Nov 8, 2017 1:51:05 PM by  Stephan Linke [Paessler Support]

Last change on Nov 8, 2017 1:55:39 PM by  Stephan Linke [Paessler Support]



Votes:

0

Hi Stephan,

excellent thank you! After successully testing this I found that the API user was of course still displayed in the sensor result. Thus I made the following modification to your script:

After:

if($LastEntry -match "logout") { $LoggedIn = "No" }

I added the following

if($User -match "PRTG System Administrator") { $LoggedIn = "No" }

It's probably not very elegant code but I am happy with the result :-)

To make this work I had to remove the "-1" that you suggested above - and other customers would probably need to replace "PRTG System Administrator" with their own API user's display name.

A very big thank you for your continuous support on this!

Best regards, Frank

Created on Nov 10, 2017 9:36:53 AM



Votes:

0

Hi Frank,

That's one way to do it :) Thanks for your perseverance as well!
Glad it works now, it took quite long, but as they say:

The journey is the reward.

Have a great weekend!


Kind regards,
Stephan Linke, Tech Support Team

Created on Nov 10, 2017 9:47:06 AM by  Stephan Linke [Paessler Support]



Votes:

0

Hello ,

any ideas why on local server i run the script and it works it shows the correct Users that are logged . but when i use it with sensor it shows me 0 users.

thanks for help

Created on Nov 14, 2017 1:40:44 PM



Votes:

0

Did you set the security context of the sensor in its settings to be an administrative user? It needs to access the registry and log files that may not be available to the currently configured user account.


Kind regards,
Stephan Linke, Tech Support Team

Created on Nov 15, 2017 8:21:43 AM by  Stephan Linke [Paessler Support]

Last change on Nov 15, 2017 2:38:55 PM by  Stephan Linke [Paessler Support]



Votes:

0

Oh, i knew i missed something .

its working great now . thanks alot.

Created on Nov 15, 2017 2:30:24 PM



Votes:

0

You're most welcome :)


Kind regards,
Stephan Linke, Tech Support Team

Created on Nov 15, 2017 2:39:17 PM by  Stephan Linke [Paessler Support]



Votes:

0

Hi Stephan,

We still cannot get the script to output a value to our Sensor. I see in the script itself:

End {
      # If we have the $prtg parameter set, the script will output data using the EXE/Script format (<value>:<message>}}}

Do we need to enable this $prtg parameter somewhere in the script in order to get the result into a sensor? If so, how do we do that? (It isn't immediately obvious from the script itself.)

Thanks

Todd

Created on Dec 19, 2017 9:08:01 PM

Last change on Dec 20, 2017 7:51:19 AM by  Stephan Linke [Paessler Support]



Votes:

0

Hi Todd,

The -prtg switch is no longer necessary, as the output is always posted in PRTG format. I understand that you do get results when the script is run manually, right? It should also output an actual message stating the amount of users and a list of them. Is that the case? To recap:

  1. Make sure that the user used for PRTG access is administrative
  2. Check if it works with using the credentials of the parent device (in the sensor settings).
  3. Make sure that you're indeed using the passhash, and not the password of the account
  4. The account used for the PRTG Probe Service needs access to
    %programdata%\Paessler\Logs (Web Server)
  5. Check if the script is saved without BOM via Notepad++
  6. PRTG is able to execute PowerShell scripts properly
    Can't think of any others right now... let me know if either step worked :)

Kind regards,
Stephan Linke, Tech Support Team

Created on Dec 20, 2017 8:00:01 AM by  Stephan Linke [Paessler Support]

Last change on Dec 20, 2017 8:00:17 AM by  Stephan Linke [Paessler Support]



Votes:

0

Hi Stephan,

your script is still running without issues and I only have a follow up question regarding the time interval of the sensor and the values in the log file.

I have run this sensor with 5 and 10 minute intervals and I found that the result (=Last Message) always displays the same amount of logged in users throughout the day, even if a user logs out - up until midnight; then the user count clears to zero.

So I would guess that the script opens the same log file during 24h and thus always find all users that have logged in during the whole day - as opposed to only show the users that are or have been logged in since the last sensor check interval. Correct?

If that was the case then the result unfortunately is not as meaningful as I thought...

Is there a way around this? i.e. could we only display the 'currently' (in the last sensor check interval) logged in users? If yes, how?

Thanks again for looking into this! Best regards, Frank

Created on Feb 6, 2018 3:51:19 PM



Votes:

0

Hey Frank,

The script should actually only show the logged in users...when you execute the script manually, you'll see a list of users with the LoggedIn flag set accordingly - does that match the current user count?


Kind regards,
Stephan Linke, Tech Support Team

Created on Feb 6, 2018 4:22:22 PM by  Stephan Linke [Paessler Support]



Votes:

0

Hi Stephan,

I can see the 'Logged In' flag when running the script manually but this list shows more users than that are currently logged in. Also it clearly shows that some of these users have a 'Last Seen' flag that was 2 to 6 hours ago...

Could this mean that PRTG counts old session as still active? - i.e. when a user simply closes the browser window as opposed to logout properly? - and/or that a PRTG user session does not expire after some time or only at midnight?

Thanks for further clarification and best regards, Frank

Created on Feb 9, 2018 2:39:23 PM



Votes:

0

Nope, it shouldn't count inactive sessions: $ActiveUsers = ($loggedInUsers | Where-Object -FilterScript {$_.'Logged in' -match "Yes"}); See, it filters the active users, only users that have "Logged In" set to yes are counted. Furthermore, only logs from the current day are checked. Really not sure what's causing this ... :(

Created on Feb 12, 2018 7:12:02 AM by  Stephan Linke [Paessler Support]



Votes:

0

Starting with PRTG Release 18.4.46.1706 this feature is now built-in.

You can now see the names of all PRTG user accounts that are currently logged in to your PRTG instance! Open the PRTG System Status page in the web interface via the main menu (Setup | PRTG Status) and look at section Software Version and Server Information. There is the new entry Active User Sessions that shows all currently logged in PRTG users.

Created on Nov 28, 2018 7:27:48 AM by  mkoerber (2) 1



Votes:

0

While this does not address the original question, at least it's now possible in current version to check in real time who is logged in; this information is available in the Web interface (system state / software version and server informations / active user sessions)

Created on Nov 28, 2018 8:19:59 AM



Votes:

0

Yeah, the script is basically to correlate the amount of users logged in to performance issues that may occur within PRTG, due to many search queries or something like that :)


PRTG Scheduler | PRTGapi | Feature Requests | WMI Issues | SNMP Issues

Kind regards,
Stephan Linke, Tech Support Team

Created on Nov 28, 2018 9:12:39 AM by  Stephan Linke [Paessler Support]



Votes:

0

Looks like the new update (18.4.46.1754) mirrors this functionality:

PRTG Status You can now see the names of all PRTG user accounts that are currently logged in to your PRTG instance! Open the PRTG System Status page in the web interface via the main menu (Setup | PRTG Status) and look at section Software Version and Server Information. There is the new entry Active User Sessions that shows all currently logged in PRTG users.

Created on Nov 29, 2018 5:36:51 PM



Votes:

0

since a couple of weeks, this doesn't work anymore. we get the following error

[18.02.2021 13:44:42]   information   Using D:\Data\PRTG Network Monitor\Logs\webserver\WebServer.log
[18.02.2021 13:44:42]   information   Log is 55626 lines long
[18.02.2021 13:44:42]   information   Loading Users...
[18.02.2021 13:44:42]      error      Could not access PRTG webinterface. Please check URL and credentials!
0:Could not access PRTG webinterface. Please check URL and credentials!
The URI prefix is not recognized.
[18.02.2021 13:44:42]     success     Found 0 users
0:0 user(s) currently logged in 

the credentials are correct and also the url. is there anything I could check?

Created on Feb 18, 2021 12:50:21 PM

Last change on Feb 18, 2021 3:26:59 PM by  Felix Wiesneth [Paessler Support]



Votes:

0

Hi Jörg
I would recommend to take a look here. It seems like the issue already occurred.


Kind regards

Felix Wiesneth - Team Tech Support

Created on Feb 19, 2021 2:38:01 PM by  Felix Wiesneth [Paessler Support]



Votes:

0

Hi @Stephan Linke,

I tried the script and only got it half working. I already tried everything mentioned above. The Console outputs Seccess, but shows that 0 Users are logged in.

I Added @cyberclaus62 command to Output the URL that is used, which seems correct, username and passhash are inserted correctly. But when i paste the link into my browser only the Loginpage opens.

[14.06.2021 12:06:58] information Using C:\ProgramData\Paessler\PRTG Network Monitor\Logs\webserver\WebServer.log [14.06.2021 12:06:58] information Log is 28937 lines long [14.06.2021 12:06:58] information Loading Users... [14.06.2021 12:06:58] information https://prtg:443/config_report_users.htm?username=prtgadmin&passhash=h:123456789 [14.06.2021 12:06:58] success Found 0 users 0:0 user(s) currently logged in

I Think the script is working correctly, but doesnt prtg let me log in with credentials in the URL? I'm using PRTG version 21.2.68.1492.

Created on Jun 14, 2021 10:15:12 AM



Votes:

0

The configured passhash is not to be preceeded by h:, only the numerical number is required. Additionally, ensure that the First Run Wizard in IE is also disabled. The error indicates that this is likely the issue with your instance :)

Created on Jun 14, 2021 11:24:54 AM by  Stephan Linke [Paessler Support]



Votes:

0

Hi Stephan,

I removed the h: from my passwordhash, but it didnt change anything. The Firts Run Wizard is also disabled. I confirmed the dialog by hand and disabled it in gpedit and Registry. For me in German the local GPO Name is "Ausführung des Anpassungs-Assistenten verhindern", right?

Still getting Powershell to write "Success" with 0 Users. As already mentioned, if I copy the generated URL to my Browser it only shows the PRTG Login Page. It SHOULD log in automatically (due to username and Passhash given in URL) and show the Users List, which doesnt happen. (Same behaviour after removing h: in passhash).

Created on Jun 14, 2021 11:51:11 AM



Votes:

0

Good afternoon I put the Script PRTG-GetLoggedInUsers.ps1 in Prtg and I get the error "System Error: (code: PE022)" and I run in "Powershell SE" it works fine. thank you for your help and collaboration.

PRTG v 22.1.74.1869

Created on Mar 18, 2022 5:50:12 PM



Votes:

0

Hello juanrodrigues2022,

Did you set the "Security Context" in the sensor settings to "Use Windows credentials of parent device"?


Kind regards,
Sasa Ignjatovic, Tech Support Team

Created on Mar 23, 2022 7:57:52 AM by  Sasa Ignjatovic [Paessler Support]



Votes:

0

Good day Sasa Ignjatovic

I put another option and it gave me another error and I took the demo program that comes with the prtg to see if it was a spri and prtg error.

I put the Script Demo Powershell Script - Available MB via WMI.ps1 in Prtg and I get the error:

"The access has been denied. To resolve this issue, check your Credentials for Windows Systems in the device settings. code:( PE095)"

Security Context option Use Windows credentials of parent device

Created on Mar 23, 2022 10:53:34 AM



Votes:

0

Hello juanrodrigues2022,

Did you enter user credentials in the "Settings" tab of the device (on which you added the sensor) in the section "Credentials for Windows"?

I would suggest that you enter the user that you used to run the script manually.


Kind regards,
Sasa Ignjatovic, Tech Support Team

Created on Mar 23, 2022 12:29:50 PM by  Sasa Ignjatovic [Paessler Support]



Votes:

0

Good afternoon Sasa Ignjatovic, I got the following error PRTG versión 22.1.74.1869:

Demo Powershell Script - Available MB via WMI.ps1 System Error: (code: PE022).

perform the following step:

step 1:

Basic Device Settings

Credentials for Windows Systems

  • Domain or Computer Name : DESKTOP-**
  • User Name: user
  • Password: ***

step 2:

Basic Sensor Settings

Sensor Settings

  • Security Context Use Windows credentials of parent device

Created on Mar 24, 2022 4:47:47 PM



Votes:

0

Hello juanrodrigues2022,

I think we need to take a closer look at this sensor. Please open a support ticket, and provide us with some screenshots of the sensor (Overview, Log, Settings tab).


Kind regards,
Sasa Ignjatovic, Tech Support Team

Created on Mar 25, 2022 7:04:57 AM by  Sasa Ignjatovic [Paessler Support]



Votes:

0

Hello team! After updating on newest version of PRTG (22.2.77.2204+) webserver.log file had another output format. And sensor displayed "0".

Before update all works fine, string from log file was:

  1. 729198 2022-07-04 10:12:09 10.1.X.X "user2581-t_test" prtg.domain 443 GET /controls/edituser.htm id=12345&username=t_test&passhash=* 200 "Mozilla/5.0 (Windows NT; Windows NT 6.2; en-US) WindowsPowerShell/5.1.17763.2931"

But after update sensor zeroed data:

  1. 1559671 2022-07-04 10:25:59 10.1.X.X "Test Test" prtg.domain 443 GET /controls/history.htm id=1234&count=1&"columns=datetime, user"&output=json&_hjax=false 200 "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36"

Could you please help to correct your script for new version of PRTG software? there is no User_ID in new webserver.log file...

Created on Jul 7, 2022 8:31:42 AM



Votes:

0

There were indeed some changes to the WebServer.log in the latest version (22.2.77), which causes that the script no longer works. We would need to check if we can make some additional changes to the WebServer.log file in order to get the script working again.


Kind regards,
Sasa Ignjatovic, Tech Support Team

Created on Jul 14, 2022 5:14:48 AM by  Sasa Ignjatovic [Paessler Support]



Votes:

0

Facing the same issue, post upgrade to 22.2.77.2204+ this functionality is broken. Can someone please help provide a workaround??????

Created on Aug 9, 2022 9:47:40 PM



Votes:

0

Hi team,

Is there any update ? Same issue on 22.4.81.1532+ 6 months later ...

Created on Jan 19, 2023 2:00:23 PM



Votes:

0

I have just tested the script in the latest version (22.4.81) and it seems to be working again.


Kind regards,
Sasa Ignjatovic, Tech Support Team

Created on Jan 20, 2023 9:21:32 AM by  Sasa Ignjatovic [Paessler Support]



Votes:

0

You're right, in fact the script is working well with PowerShell ISE, but it still return 0 in PRTG on my side.

Executed with the security context of PRTG probe service it return 0 (but at least it return something). If I choose "Windows credentials of parent device" it trigger an error (sensor and script are placed on a probe, no problem with any WMI sensor, the windows account is the local admin account and it can run the script without issue)

Any idea ?

Created on Jan 20, 2023 4:22:44 PM



Votes:

0

@Dorian_PARIS,

I would suggest that you open a support ticket so that we can have a closer look at the sensor.


Kind regards,
Sasa Ignjatovic, Tech Support Team

Created on Jan 23, 2023 8:25:33 AM by  Sasa Ignjatovic [Paessler Support]




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.