Writing your own CLI tools with PowerShell: A case study of...
summary
Built a CLI called SQLTop replicates top for SQL Server that shows live queries, CPU, threads and blocking and can kill sessions; implemented in PowerShell 5.1 using .NET Sql classes instead of Invoke-SqlCmd, runs remotely from a jump box, and is open sourced on GitHub under channeladvisor. UI uses runspaces + synchronized Hashtable to gather data in parallel (used for scaling to hundreds of DBs and 250–300 concurrent deployments), a double-buffered redraw to avoid flicker, and Console.RawUI ReadKey/KeyAvailable for single‑key menus; demos include a Foreman load generator and it works during the presentation.
AI-written summary · about
chapters (16)
- 0:00Intro
- 3:02Why build tools
- 5:55SQL Top
- 11:57Challenges
- 12:24User Experience
- 13:23System Quirks
- 14:55Invoke SQL Command
- 17:22Flicker Free
- 23:17Sharing Data in State
- 30:17Running Scripts
- 36:21Code Samples
- 38:34Color
- 42:29SQLTop
- 45:25ReadKey
- 47:35ReadKey Demo
- 51:54Menu Module
related talks
40mFrom Chaos to Clarity: Taming Data with PowerShell
46mFrom Script to Tool: Building Robust, Meaningful Tools with PowerShell
49mState of The Shell
01h 26mGetting Ahead By Deleting Code
41mWhat's Cooking with PowerShell Core?
03h 41mA Scripters Next Step...
46mCreating a Complex and Reusable HTML Reporting Structure
33mBetter Ops Together: Practical PowerShell Pair Programming...
