Skip to content
Menu
The Lonely Administrator
  • PowerShell Tips & Tricks
  • Books & Training
  • Essential PowerShell Learning Resources
  • Privacy Policy
  • About Me
The Lonely Administrator

Organizing Chaos with PSWorkItems and PowerShell

Posted on August 3, 2022August 3, 2022

I spend my working days living in a PowerShell console. Over the years, I've developed many PowerShell modules to help me manage the chaos that is my work life. One area that always demands attention is managing my tasks and To-Dos. For several years I have been using the MyTasks module. This module stored tasks and supporting information in a set of XML files. The code in the module treated the XML files as databases. I was trying to avoid a dependency on a SQL Server Express installation with the idea that would be overkill.

Manage and Report Active Directory, Exchange and Microsoft 365 with
ManageEngine ADManager Plus - Download Free Trial

Exclusive offer on ADManager Plus for US and UK regions. Claim now!

ln the meantime, I finally got around to finishing and publishing the MySQLite PowerShell module. This module has a set of PowerShell functions designed to simplify working with SQLite database files. This type of database has a much smaller footprint than SQL Server Express and would streamline my task management.

PSWorkItem Database

All of this has led me to release a new PowerShell module called PSWorkitem. This module takes the MySQLite module as a dependency and will only run on PowerShell 7 on 64bit Windows platforms. You can install the module from the PowerShell Gallery.

Install-Module PSWorkItem -force

The installation process will also include the MySQLite module. Everything is stored in a single SQLite database file which you can create using Initialize-PSWorkItemDatabase.

Initialize=PSWWorkItemDatabase

The database will be created at $Home\PSWorkItem.db. This path is saved to a global variable PSWorkItemPath, which is defined when you import the module. All of the module commands that have a path to reference the PSWorkItem database use this global variable as the default value.

To create a new PSWorkItem, specify the name, a category, and a due date. You can either specify the date and time or a number of days. The default is 30 days from now.

New-PSWorkItem -name "SRV2 backup" -category SRV
New-PSWorkItem "update resume" Personal -DaysDue 15
New-PSWorkItem "New AD User script" Work -DueDate 8/15/2022 5:00PM

Categories

All tasks, or PSWorkItems as I call them, have an associated category. The module will create default categories of Work, Personal, and Other. Categories are stored in their own table in the database file. You can add your categories.

Add-PSWorkItemCategory -Name SRV -Description "server management tasks" 

The module has several commands for managing categories. Use Get-PSWorkItemCategory to view them.

PSWorkItem Categories

PSWorkItems

All of the object types in the module are based on class definitions. The module commands get data from the SQLite database and creates the appropriate object. The PSWorkItem type has a defined set of formatted views.

Get-PSWorkItem
psworkitems defualt view

The default is to display items that are due within 10 days, but you have options.

Get-PSWorkItem syntax

By default, tasks due within the next day or overdue will be displayed in red. Tasks due within three days will be displayed in yellow. The formatting is using $PSStyle values, so you might get different results depending on your console or terminal color theme.

In addition, the module will create a global variable called PSWorkItemCategory. This is a hashtable where the key is a defined category, and the value is a PSStyle or ANSI escape sequence.

$global:PSWorkItemCategory = @{
    "Work"     = $PSStyle.Foreground.Cyan
    "Personal" = $PSStyle.Foreground.Green
}

You can easily add your custom entries.

$PSWorkItemCategory.Add("Event","`e[38;5;153m")

Modifying PSWorkItems

You can update or modify existing tasks by their ID.

modify a PSWorkItem

When a task is complete, you can mark it as such.

Complete-PSWorkItem -id 8

You should be able to use the module commands to manage everything. But you can always fall back to a more hands-on approach using the commands in the MySQLite module.

Summary

I am already finding the new module to be much easier to use. I moved the database file to a shared folder in DropBox and created a symbolic link to $HOME on my desktop and laptop. This allows me to use the module commands on either system and keep everything synchronized. I hope you'll read the project's README to learn more and give this module a try. If nothing else, I'd like to think that the PSWorkItem module can serve as a template for future PowerShell modules built around a SQLite database. I have at least one other project in mind.


Behind the PowerShell Pipeline

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to print (Opens in new window) Print
  • Click to email a link to a friend (Opens in new window) Email

Like this:

Like Loading...

Related

5 thoughts on “Organizing Chaos with PSWorkItems and PowerShell”

  1. Pingback: Organizing Chaos with PSWorkItems and PowerShell - The Lonely Administrator - Syndicated Blogs - IDERA Community
  2. Berend says:
    August 4, 2022 at 7:27 am

    Due date is not adhering to the regional date settings.

    1. Jeffery Hicks says:
      August 4, 2022 at 9:27 am

      Would please post this as an issue with an example so that I can track it? Please also include your culturue (Get-Culture).

  3. Sven Böhm says:
    August 4, 2022 at 8:02 am

    Many thanks for your work, description and sharing

  4. Pingback: PSWorkItems: Powershell TODOs – Curated SQL

Comments are closed.

reports

Powered by Buttondown.

Join me on Mastodon

The PowerShell Practice Primer
Learn PowerShell in a Month of Lunches Fourth edition


Get More PowerShell Books

Other Online Content

github



PluralSightAuthor

Active Directory ADSI Automation Backup Books CIM CLI conferences console Friday Fun FridayFun Function functions Get-WMIObject GitHub hashtable HTML Hyper-V Iron Scripter ISE Measure-Object module modules MrRoboto new-object objects Out-Gridview Pipeline PowerShell PowerShell ISE Profile prompt Registry Regular Expressions remoting SAPIEN ScriptBlock Scripting Techmentor Training VBScript WMI WPF Write-Host xml

©2025 The Lonely Administrator | Powered by SuperbThemes!
%d