A Real Tool
The parts every real tool has: objects of its own, a place for its data, friendly output, and maybe a window.
Updated
Data
- Objects of Your Own: `[PSCustomObject]` (Journeyman): [PSCustomObject]@{ } builds an object of your own with named properties, so a tool you write hands back results that Sort-Object, Where-Object and Export-Csv can work with, the way they work with PowerShell's own commands, instead of lines of text.
- Where a Tool Keeps Its Data (Journeyman): A tool keeps its data in a folder of its own under $env:LOCALAPPDATA, builds the path with Join-Path, creates the folder the first time it runs, and saves and loads its objects as JSON, so what you add today is still there tomorrow, whatever folder you're in.
Friendly Output
- Friendly Output: Colors and Progress (Journeyman): Write-Progress shows a progress bar while a long job runs, so nobody wonders whether it's stuck, and $PSStyle colors make the important lines stand out on the screen, as long as the colors stay in what you show and never go into the objects a tool hands back.
- Your Script Can Have a Window Too (Freelancer): On Windows, a script can open a small window of its own with .NET's Windows Forms: a form, a list, a button and a label, with a script block that runs when the button is clicked, so a colleague who would rather click can use your tool without typing a command.
Exercise: A Recipe Box Module
- Exercise: A Recipe Box Module (Freelancer): Turn a recipe-box module that prints lines of text into a real tool, so its recipes come back as objects you can sort and filter, live in a folder of their own under $env:LOCALAPPDATA, show in color on the screen without a color in the data, and fill a small window with a list and a button, while a Pester check tries it on a recipe box of its own.