PowerShell: Display A Menu And Get a Valid Choice

While it’s normally best practice to not display anything on the host and to batch as much as possible with PowerShell; sometimes you need a UI.  Here’s a pair of functions to display a menu on the screen, automatically number the possible responses and only return when a valid choice is made. Continue reading “PowerShell: Display A Menu And Get a Valid Choice”

PowerShell: A Logging Function

Often you need to record what a script does to a file.  You can easily get something going with Start-Transcript but sometimes you want to control what is written with a bit more granularity.

So here’s a function I tend to re-use in my scripts.  It takes text output and writes it both to a text log file and to the Verbose output stream. Continue reading “PowerShell: A Logging Function”

PowerShell: A Function Template

“Stuff that saves time” is a pretty good credo for PowerShell.  With that in mind, if you’re going to write lots of functions a template can both save you a bit of typing and remind you about important bits to include.

Here’s mine, with a few comments afterwards.

Continue reading “PowerShell: A Function Template”