It has taken some discipline but I have finally gotten the hang of using the command history file maintained by PSReadline. Even though Set-PSReadlineOption has a few options on how to use this file, in my experience I have felt the need to handle a few things on my own. Here’s my take.
The other day I posted an article about custom properties which wrapped up with a look at Update-TypeData. The goal is not so much to make your scripts or modules easier to use, but rather to increase efficiency at the command prompt. When running commands interactively I want to get the information I need as easily as possible. In my PowerShell profile scripts I have code that defines a number of type extensions to make my life easier. I thought I’d share some of them with you.
I am always stressing that PowerShell is all about the objects. If you keep this in mind, PowerShell is pretty easy to use. Get a bunch of things, and select the details that you want to see or work with. Out of the box PowerShell gives you some very rich objects to work with from simple files to Active Directory users. What I like even more is that you can create your own properties “on-the-fly” to meet your needs. It is almost like magic. You can create new properties practically out of thin air. But sometimes even this process can get a bit tedious or overwhelming. Let me offer some solutions.
For awhile now I’ve been working on a PowerShell project that I use every day. I am always in a PowerShell prompt and because I always seem to have little things like phone calls or family events that I need to keep track of, I wrote a “tickler” system. The events are stored in a SQL database any my PowerShell commands query for upcoming events. My module has commands for setting up the database, querying commands and modifying data. All the SQL stuff is done without using the SQL PowerShell module because I didn’t want to take a dependency on it and I want to write something that will work cross-platform. I wasn’t sure if the SQL cmdlets would be 100% compatible, plus my needs were simple so I found it easier to write my own query function. Today, I decided to launch a semi-public beta and share it with you.
I’m always looking for ways to help teach PowerShell and the other day I thought why not have PowerShell teach you itself? I have created a PowerShell script that dynamically generates a quiz on cmdlets and functions installed on your computer. In short the quiz question shows you a command synopsis and then presents a menu of possible answers. You select the answer. Given the verb-noun pattern of command names this *should* be easy, but you might be surprised.