I write a lot of PowerShell modules. And probably like you, I am working on more than one project at a time. I was finding it difficult to keep track of what I was working on and what I might be neglecting. So I turned to PowerShell and created a tool that I use to keep on top of my projects. The PowerShell module is called PSProjectStatus and you can install it from the PowerShell Gallery. You can find the project on GitHub, but I thought I'd provide an introduction here.
ManageEngine ADManager Plus - Download Free Trial
Exclusive offer on ADManager Plus for US and UK regions. Claim now!
Class-Based
The module is built around a PowerShell class that defines a PSProject object.
Class PSProject {
[string]$Name = (Split-Path (Get-Location).path -Leaf)
[string]$Path = (Convert-Path (Get-Location).path)
[datetime]$LastUpdate = (Get-Date)
[string[]]$Tasks
[PSProjectStatus]$Status = "Development"
[string]$GitBranch
[string]$UpdateUser = "$([system.environment]::UserDomainName)\$([System.Environment]::Username)"
[void]Save() {
$json = Join-Path -Path $this.path -ChildPath psproject.json
$this | Select-Object -Property * -exclude Age | ConvertTo-Json | Out-File $json
}
}
The data to create the class is stored in a JSON file, psproject.json, which is stored in the module's root directory. The PSProjectStatus module has commands to manage this object and the JSON file.
Creating a Status
To create a new status, change to the root of your module and run New-PSProjectStatus.
The Status property is based on an enumeration.
enum PSProjectStatus {
Development
Updating
Stable
AlphaTesting
BetaTesting
ReleaseCandidate
Patching
UnitTesting
AcceptanceTesting
Other
}
The default is Development. I've tried to add enough values to accommodate almost any situation. When you create a new PSProject status, information is written to a JSON file.
If a git branch is detected, it will be included.
Updating a Status
To update a status, use the Set-PSProjectStatus command.
You can specify comma-separated list of tasks. I tend to keep them high-level and broad. If you want to add a task, use the -Concatentate parameter. Currently, there's no way to remove a task other than manually editing the JSON file. If you have your project open in VSCode, that's not too difficult to do. You can always manually edit the file. If you need to update the LastUpdate value, run Get-Date -format o | Set-Clipboard and paste the value into the file.
The Age property is a ScriptProperty added by extending the PSProject type.
Getting a Status
Normally, you will run Get-PSProjectStatus from the module root. The default output if a formatted table. This is the output you see when creating or setting a status. The module includes a list view.
The list makes it easier to view tasks.
To manage everything on my plate, I can use this module in a PowerShell 7 script file.
#requires -version 7.2
#requires -module Microsoft.PowerShell.ConsoleGuiTools
#open a project using the PSProject status
Import-Module PSProjectStatus -Force
#get all projects
$all = Get-ChildItem -Path C:\Scripts -Directory | Get-PSProjectStatus -WarningAction SilentlyContinue
#display the projects in Out-ConsoleGridview and open the selected one in VS Code
$all | Sort-Object Status, LastUpdate |
Select-Object Path, Status, @{Name = "Tasks"; Expression = { $_.Tasks -join ',' } },
Gitbranch, LastUpdate |
Out-ConsoleGridView -Title "PSProject Management" -OutputMode Single |
ForEach-Object { code $_.path }
The script searches C:\Scripts for sub-folders with a psproject.json and displays the projects using Out-ConsoleGridview. From here, I can select a single module and open it in VS Code.
Try It
I hope you'll install the module and give it a spin. I'd like to know what you think and how it works for you. What would add value? I already have ideas for enhancements, but I'd live to hear what's on your mind. You are invited to use the repository's Discussions section.
2 thoughts on “Introducing PSProjectStatus”
Comments are closed.