• 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 an RDS Server Trigger and Script with ControlUp Academy

Posted on May 10, 2024

A discussion on setting up a trigger for an email notification for an RDS server with a powershell script was held. It was suggested to check the Windows event log and run a script when the trigger is fired. The email should only be sent once and not for all 3 servers in the folder. ControlUp Academy offers training for scripting.


Read the entire ‘Setting up an RDS Server Trigger and Script with ControlUp Academy’ thread below:

Hello,

I am trying to setup a trigger that will sends me an email when one of the 3 RDS servers (either one) in the folder will reach 10 or more sessions. Eventually this trigger will execute the powershell script.

I would like to get only one notification from the first server and not form the other 2. Anyone have an idea how to accomplish this?


How comfortable are you with scripting?

ControlUp evaluates triggers against individual objects. As in each machine is considered individually.

The basic idea is that you setup a trigger that runs a script. The script checks if the trigger has already fired for another machine. Typically via the Windows event log. Something like this:

“`$targetComputer = $args[0]

$eventLogName = "ControlUp Repeat Triggers"

$id = 1000 ## Needs to be unique between use cases!

$threshold = 1

$timeframe = 24##hours

try{

New-EventLog -LogName "Application" -Source $eventLogName -erroraction stop

}

catch

{

Ignore source is already registered error

}

check how many events have been logged

$filterhash = @{logname="application";providername=$eventLogName;id=$id;starttime=([datetime]::Now.AddHours(-$timeframe))}

[array]$number = Get-WinEvent -FilterHashtable $filterhash

if($number.count -le $threshold)

{

Write-Host "FOLLOW UP ACTION"

Send-MailMessage -To "[alerts@example.com](mailto:alerts@example.com)" -From "[controlup@example.com](mailto:controlup@example.com)" -Subject "example subject" -Body "example body"

} else

{

##write the event log

Write-EventLog -LogName Application -Source $eventLogName -EntryType Information -Message "Dummy" -EventId $id

}“`

Continue reading and comment on the thread ‘Setting up an RDS Server Trigger and Script with ControlUp Academy’.  Not a member? Join Here!


Categories: All Archives, ControlUp Scripts & Triggers
Topics: Automation & Alerting, Logs, Microsoft Windows, PowerShell, Scripts, Triggers

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..