en-US/about_MyTimer.help.txt

TOPIC
    about_mytimer
 
SHORT DESCRIPTION
    This module contains several commands designed to work with a very simple timer.
    The commands are based on an extremely basic principal: how much time has
    elapsed between two events? You can easily do this now with New-Timespan
    or simply subtracting one datetime from another. This module takes the
    simplest approach possible: save the current date and time to a read-only
    variable and when you are ready, calculate a timespan from that variable.
    Even though the commands reference a timer object there really isn't
    anything fancy or complicated. It is simply a variable that you can name,
    that has a datetime value.
 
LONG DESCRIPTION
    There's no .NET magic or anything complicated. The module commands are
    designed to make it easier to manage all of this. You can even create
    multiple timers at the same time in case you want to stop them at different
    intervals. When you are ready to stop a timer, run Stop-Mytimer and
    specify the timer name.
 
    Use Get-MyTimer to view the status of all your timers but without stopping
    them. Use Set-MyTimer if you want to modify a setting such as description.
    All timer variables are stored in a global variable called
    myTimerCollection. You can use Remove-MyTimer to delete items from the
    collection.
 
    EXPORTING AND IMPORTING
    If you need to persist timers across PowerShell sessions you can export a
    single timer or all timers with Export-MyTimer. Timers will be exported to
    an XML file using Export-Clixml. In the other PowerShell session use
    Import-MyTimer to recreate them in the current session. The running time
    will continue from when they were first created.
 
EXAMPLES
    Create a single timer:
 
    PS C:\> Start-MyTimer -Name A
     
    Name Start Stop Duration Running Description
    ---- ----- ---- -------- ------- -----------
    a 12/12/2018 11:34:25 AM 00:00:00 True
 
    Start multiple timers:
 
    PS C:\> Start-Mytimer B,C
     
    Name Start Stop Duration Running Description
    ---- ----- ---- -------- ------- -----------
    B 12/12/2018 11:34:51 AM 00:00:00 True
    C 12/12/2018 11:34:51 AM 00:00:00 True
 
    Start a timer with a description:
 
    PS C:\> Start-Mytimer D -description "work stuff"
     
    Name Start Stop Duration Running Description
    ---- ----- ---- -------- ------- -----------
    D 12/12/2018 11:35:12 AM 00:00:00 True work stuff
 
    Note that timer names must be unique. You can view status of all running
    timers:
 
    PS C:\> get-mytimer
     
    Name Start Stop Duration Running Description
    ---- ----- ---- -------- ------- -----------
    a 12/12/2018 11:34:25 AM 00:01:38.0954883 True
    B 12/12/2018 11:34:51 AM 00:01:12.5691189 True
    C 12/12/2018 11:34:51 AM 00:01:12.5621210 True
    D 12/12/2018 11:35:12 AM 00:00:51.8095814 True work stuff
 
    Stopping a timer will update the duration and mark it as no longer running.
 
    PS C:\> stop-mytimer C
     
    Name : C
    Start : 12/12/2018 11:34:51 AM
    End : 12/12/2018 11:37:10 AM
    Duration : 00:02:19.3153311
    Description :
 
    You can also export and import timers if you need them to persist across
    PowerShell sessions. Otherwise the timers are removed when your PowerShell
    session ends.
 
KEYWORDS
    - Timer
    - Timespan