Countdown in a PowerShell GUI

The following script allows to include a countdown in a PowerShell-based GUI.

Basically, a “timer” object is used to decrement a variable.

In this example:

  • The countdown is initialized to 10
  • Then, a timer is used to run a function every second
  • This function decrement the countdown
  • When the value of the countdown equal 0, another function is called to launch the action