![Run tasks on timers in PowerShell](https://ytimg.googleusercontent.com/vi/8dZbdl3wzW8/hqdefault.jpg)
The .NET Framework has a class named Timer in the System.Timers namespace, defined in System.ComponentModel.TypeConverter.dll. There are two constructors for the Timer class, one with zero parameters and one that accepts a single "double/" value as input. The value /"double/" is the interval, in milliseconds, over which the timer will run.
Once you've created a Timer object, you use the Register-ObjectEvent command to register for the .NET /"Elapsed/" event. On this same command, the -Action parameter allows you to specify a PowerShell ScriptBlock (aka anonymous function) that will be executed every time the Timer runs out.
Producer: Trevor Sullivan
Website: https://trevorsullivan.net
Patreon: https://patreon.com/trevorsullivan
Twitter: https://twitter.com/pcgeek86
LinkedIn: https://www.linkedin.com/in/trevor-sullivan/
#Microsoft #PowerShell #Developer
Please take the opportunity to connect and share this video with your friends and family if you find it useful.
No Comments