Powershell One-liner of the Day: XenDesktop Users that have not Logged on in 60 Days or More

Just a simple one-liner to get a listing of all users that have not logged into their XD desktop in 60 days or more – this is for static desktops or XD PvD.

Requires:

  • XenDesktop PowerShell SDK (studio commandlets)
  • AD Powershell commandlets

[code language=”powershell”]
asnp Citrix*
Get-BrokerDesktop -MaxRecordCount 2000 | Where {((Get-Date) – $_.LastConnectionTime).Days
-gt 60} | sort LastConnectionTime |
Select DNSName,LastConnectionTime,@{Name="UserName";Expression={$UserN = $_.AssociatedUserNames.Replace("DOMAINHERE\",""); $UserObj
= Get-ADUser
-Filter {Name -eq $UserN}; "$($UserObj.GivenName) $($UserObj.Surname)"}}
[/code]

  • Use MaxRecordCount for large environments
  • Replace “DOMAINHERE\” with your domain

Leave a Reply