Jump to content
Welcome to our new Citrix community!
  • 0

How find the last time user has logged in to the Citrix-environment?


tylital520

Question

Hi!

 

I have the following problem; I need to find out when a user has logged in to our Citrix-environment the last time. We are using XenDEsktop 7.14.1 from which we publish desktops and apps to users. I need this information from all of our Citrix users.

 

The problem is that I cannot simply check the Active Directory LastLogon/LastLogonDate parameters, because our users access the environment from another Active Directory forest, so in AD they are represented as Foreign Security Principals.

 

I've been trying to figure out what other information I could use to determine this. We use Citrix UPM, is there a file that updates in users profile folder at each logon? Or can I get some info from NetScaler VPX? We have enterprise licenses. Or does something get logged in on Controllers or StoreFront -servers, or Directory when a user logs in?

 

I would need to get this information via PowerShell. All help would be much appreciated. And apologies if this is a wrong place for the thread. I really didn't know where I should put this.

Link to comment

7 answers to this question

Recommended Posts

  • 1

I ended up writing a PowerShell script that I put as a login script on Group Policy Object that is targeted to Citrix-servers/desktops.

 

Now every time a user logs in to one of our Citrix servers (published desktop or application) the username and login time is written into a csv-file.

 

Once a day another script goes through the file, finds duplicates and preserves only the latest entry. It then compares the time stamp of the latest entry and the current time (when the script is being run) and if the difference is greater than X days, something is being done :)

  • Like 2
Link to comment
  • 0
On 7/7/2017 at 6:37 AM, tylital520 said:

I ended up writing a PowerShell script that I put as a login script on Group Policy Object that is targeted to Citrix-servers/desktops.

 

Now every time a user logs in to one of our Citrix servers (published desktop or application) the username and login time is written into a csv-file.

 

Once a day another script goes through the file, finds duplicates and preserves only the latest entry. It then compares the time stamp of the latest entry and the current time (when the script is being run) and if the difference is greater than X days, something is being done :)

 

 

have how to share this script?

Link to comment
  • 0
On 3/21/2020 at 2:03 AM, Luis Felipe de M.G.P. Nunes said:

 

 

have how to share this script?

 

You might be able to get this information via Monitor API: https://developer-docs.citrix.com/projects/monitor-service-odata-api/en/latest/

Here's what I tried with PowerShell:

# Get users session data:
$users = Invoke-RestMethod -Method Get -Uri "http://your_delivery_controller.domain.com/Citrix/Monitor/OData/v4/Data/Users?`$expand=Sessions" -Credential (Get-Credential)

# You can check the returned value the following way:
$users.value

# Get users who have the session information:
$users.value | Where {$_.Sessions -ne $null}

# Select the first returned user who has session information:
($users.value | Where {$_.Sessions -ne $null}) | Select -First 1

# Check that users sessions:
($users.value | Where {$_.Sessions -ne $null}) | Select -First 1 | Select -ExpandProperty Sessions

Now I am not sure why not all users have session data. Maybe this has to do with Monitor DB grooming settings: https://docs.citrix.com/en-us/xenapp-and-xendesktop/7-15-ltsr/director/data-retention.html For example we are using Advanced edition so it might only show the session data from the past 7 days.

 

But we would need a confirmation from Citrix whether the following query returns the information we are looking for (last login of each user). I think the ModifiedDate (in that returned session data) is a good candidate to check that. If the data is correct, you can quite easily write the script and schedule it to run on a daily basis.

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...