PowerShell Cookbook

Twitter Updates

    follow me on Twitter

    Search

    Categories

     

    On this page

    PowerShell Activity Tracker

    Archive

    Blogroll

    Disclaimer
    I work for Microsoft.

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

    RSS 2.0 | Atom 1.0 | CDF

    Send mail to the author(s) E-mail

    Total Posts: 252
    This Year: 3
    This Month: 0
    This Week: 0
    Comments: 736

    Sign In

     Tuesday, October 20, 2009
    Tuesday, October 20, 2009 5:07:26 PM (Pacific Daylight Time, UTC-07:00) ( )

     

    Download: http://www.leeholmes.com/projects/ActivityTracker/ActivityTracker.zip

    Over the summer, The Scripting Guys ran an excellent series for the 2009 Summer Scripting Games. They asked me to be a guest commentator for an event, and it turns out that it was something I’d been toying with in one version or another for some time.

    The topic of this event was an Activity Tracker. In your work life, it is incredibly helpful to know how you spend your time. Personally, it greatly helps improve your estimation skills: did you really spend as much time on the project as you thought you would? Professionally, it helps you remember important events for a given time period. For example, pulling status reports together for a manager, or reviewing your year’s accomplishments in preparation for your yearly review.

    I’ve been using an activity tracker in one way or the other for several years now, and definitely consider it a core tool / technique.

     

    Activity Tracker

    A light-weight personal productivity tool

    Activity Tracker helps you analyze your time by infrequently asking the simple question: “What are you doing?

    clip_image002

    Installation

    1)      Copy Start-ActivityTracker.ps1 to your local computer

    2)      Install the PowerBoots UI scripting library into your Modules directory (http://powerboots.codeplex.com). Note: PowerBoots includes a “Functions” directory. Delete everything in it before launching the first time.

    3)      Place a shortcut to the following command in your Startup folder:
    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noprofile -command Start-ActivityTracker -AsApplication

    4)      (First time only) Launch the shortcut from your Startup folder

    How it Works

    Activity Tracker follows the same principles as a traditional software sampling profiler, but instead samples humans. By randomly recording your current task, Activity Tracker lets you analyze your answers as a fairly faithful proxy for how you actually spent your time. If 20% of your answers were “Status Meeting,” then you spent close to 20% of your time in status meetings.

    An Alternative to Sampling

    An alternative to the sampling approach is an instrumentation approach: faithfully recording your transition between tasks. Activity Tracker avoids this design, since asking humans to faithfully record transitions between tasks is enormously error-prone. For example, you might not log a task transition for a task that you consider inconsequential (for example, “Checking email”,) when in fact that task may account for a significant portion of your day. Some software attempts to address the human element by tracking window titles, but the level of data captured by window titles often does not map well to the task they support.

    Using Activity Tracker

    Activity Tracker is a PowerShell script. It spawns a new instance of PowerShell to run itself, but also lets you specify the –AsApplication flag if you want it to have a unique name for the resulting exe. This new executable is simply a copy of PowerShell.exe.

    Once launched, Activity Tracker sits in the background. Once in awhile (randomly, between 5 and 25 minutes,) it asks you the question, “What are you doing?” It stores your previous answers in a list until you exit the program, which lets you easily re-use your answers to previous questions.

    When you press OK, it adds your answer (along with the current window title) to a file in “My Documents\ActivityTracker” – one file per week. The file is named to correspond to the date on the first day of the week.

    If you don’t answer within four minutes, it dismisses the dialog and checks your Outlook calendar. If you are in a meeting, it records the title of that meeting. If you aren’t in a meeting, it records nothing. This lets you keep the Activity Tracker running when you go home for the day without polluting your journal files.

    Slicing and Dicing

    The Activity Tracker records its output as a simple CSV file. Knowing that, you can slice and dice results to your heart’s content. For example, to easily get a summary of your week:

                                                                                                                            
    PS >Import-Csv temp.csv | Group Activity | Sort -Descending Count         
                                                                              
    Count Name                      Group                                     
    ----- ----                      -----                                     
       23 Hubble Space Telecsope... {@{Date=5/20/2009 8:24:19 AM; WindowTi...
        8 Meeting: Design review    {@{Date=5/20/2009 1:10:21 PM; WindowTi...
        5 Meeting: Team meeting     {@{Date=5/20/2009 3:10:20 PM; WindowTi...
        4 Email                     {@{Date=5/20/2009 8:04:26 AM; WindowTi...
        3 Scripting games           {@{Date=5/19/2009 6:09:16 PM; WindowTi...
                                                                                                                                                   <?xml:namespace prefix = o />

     

    To count how many hours you spent on a task, simply divide by four.

    Dependencies

    Activity tracker uses the PowerBoots UI scripting library: http://powerboots.codeplex.com/.

    Comments [0] | | #