• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
ControlUp Community

ControlUp Community

Connect, Learn, and Grow

  • Blog
  • Podcast
  • Meetups
  • Archives
  • Categories
    • ControlUp One Platform
    • ControlUp for Apps
    • ControlUp for Compliance
    • ControlUp for Desktops
    • ControlUp Scripts & Triggers
    • ControlUp Synthetic Monitoring
    • ControlUp for VDI
  • Topics
  • Events
    • Logos & Wallpaper
    • ControlUp.com
  • Join

Setting Up a Trigger for Identifying Unused VMs in ControlUp Focus Discussion.

Posted on June 20, 2025

Several users discussed how to set up a trigger for identifying unused VMs older than 45 days, specifically in relation to the ControlUp environment. Suggestions were given about using the built-in Session Activity report or APIs to identify machines with no recent logins. Some users mentioned testing and recoding scripts for different hypervisors. One user also brought up the issue that not all VMs have a Horizon agent.


Read the entire ‘Setting Up a Trigger for Identifying Unused VMs in ControlUp Focus Discussion.’ thread below:

I’d like to setup a trigger to identify any unused VMs older than 45 days. Has anyone done this before? We have persistent VMs used by contractors, and we are not alerted when their contract ends…


What hypervisor? We have one for Azure and are currently testing one for Citrix (on-prem and cloud)

AZ Show Resources Not Used in Time Period – ControlUp Script Library


vSphere on Prem running Omnissa Horizon workloads

I thought about searching for logonEventID = 4624 and parsing it for a date…


Where Omnissa have just announced that they won’t be producing a new PowerShell module after the current one stops working when they completely move away from SOAP (to REST)! 😒 It’s a good job that I’ve already recoded (but not released) many of our existing Horizon scripts to use REST.

A VMware/Omnissa one could come relatively soon as the idea was that the Citrix one that is currently in test, using ControlUp Streaming DB data to get usage (or lack of it), could be fairly easily extended to cover Horizon too – watch this space!


My issue is that not all of the VMs have a Horizon agent. Some are just VMs running in vSphere that users RDP into. The REST API would not see those VMs. But they all have ControlUp agents.

I was thinking of how I could use something like this.

PowerShell Script: Get Last User Logon Time with 90-Day Alert

Define the logon event ID for successful logons

$logonEventID = 4624

Get the most recent logon event (excluding system accounts)

$lastLogon = Get-WinEvent -FilterHashtable @{

LogName = ‘Security’

ID = $logonEventID

} -MaxEvents 1000 | Where-Object {

$_.Properties[5].Value -ne ‘ANONYMOUS LOGON’ -and

$_.Properties[5].Value -ne ‘SYSTEM’

} | Sort-Object TimeCreated -Descending | Select-Object -First 1

if ($lastLogon) {

$user = $lastLogon.Properties[5].Value

$time = $lastLogon.TimeCreated

Write-Output "Last user logon: $user at $time"

# Calculate days since last logon

$daysSinceLogon = (New-TimeSpan -Start $time -End (Get-Date)).Days

# Trigger alert if more than 90 days

if ($daysSinceLogon -gt 90) {

Write-Warning "ALERT: Last user logon was more than 90 days ago!"

}

} else {

Write-Output "No user logon events found."

}


Hi @member, since you have the CU agents on these machines, why not use the built-in Session Activity report?

select custom timeframe for last 45 days, select the relevant EUC / Machines folder, and check which machines did have logins in the last 45 days

all other machines had zero logins in the last 45 days

you can also export this data via our API, and compare to list of existing Horizon machines using a script

Continue reading and comment on the thread ‘Setting Up a Trigger for Identifying Unused VMs in ControlUp Focus Discussion.’.  Not a member? Join Here!


Categories: All Archives, ControlUp Scripts & Triggers
Topics: Automation & Alerting, Citrix, Cloud Computing, ControlUp Agent, ControlUp Script Library, Microsoft, Microsoft Azure, Microsoft RDP, On-Premise, PowerShell, Reporting, Scripts, Security, Triggers, VMware

Ask Us Anything, Connect, Learn, and Grow with the ControlUp Community!

Login to the ControlUp Community to ask us anything, stay up-to-date on what’s new and coming soon and meet other like-minded techies like you.

Not already a member? Join Today!

Primary Sidebar

ControlUp Academy

Enroll in ControlUp Academy for expert-led technical training, equipping you with skills to effectively deploy, manage, and grow your ControlUp investment.

Learn here >

Rotating Images

Hidden Gem from our Community on Slack!

ControlUp Betas - What's Coming Next?
NEW ControlUp Features - Stay Up-to-Date!
ControlUp Scripts - Scripting, Zero to Hero
Latest KB Articles - Be the First to Learn
Did you Know - with Sivan Kroitoru
Practical Perspectives Technical Use Case Training

Video Tutorials Library

Visit our technical how-to videos, offering step-by-step tutorials on advanced features, troubleshooting, and best practices.

Watch here >

ControlUp Blog

Check out the ControlUp blog for expert advice and in-depth analysis.

Read here >

ControlUp Script Library

Visit the ControlUp technical script library, which offers a multitude of pre-built scripts and custom actions for your monitoring and troubleshooting requirements.

See here >

ControlUp Support

Visit the ControlUp support home and to delve deeper into ControlUp solutions.

Browse here >

Download ControlUp RealTime DX

Start with ControlUp for real-time end-user environment insights, swift troubleshooting, and unprecedented performance optimization. Download now.

Download here >

Footer

      

ControlUp Community
Of Techie, By Techie, For Techie!

Terms of Use | Privacy Policy | Security
Dive Deeper, Learn more at ControlUp.com

  • facebook
  • twitter
  • youtube
  • linkedin

© 2023–2025 ControlUp Technologies LTD, All Rights Reserved.

We use cookies to ensure that we give you the best experience on our website. by continuing to use this site you agree to our Cookie policy..