Chapter 2. Customizing MSH
Now that we’ve seen a handful of the features that MSH has to offer, it’s time to settle in and become familiar with the new environment. In this chapter, we’ll look at some of the practical tasks that will save a lot of time in the future.
Load and Save Scripts
All of the examples so far have followed the same procedure: MSH presents a prompt and waits for your input, you type a command, the command is processed, the output is displayed, and the cycle repeats. This is useful for interactive command line use, invoking cmdlets one by one, building pipelines, and general day-to-day use.
However, like cmd.exe, MSH can take its instructions from a file instead of receiving commands from a keyboard. This enables us to create complex sequences that perform one or more tasks and save these scripts to disk. In this way, it’s possible to build up a library of scripts that encapsulate common repetitive tasks. With this library on hand, it’s easy to save time and quickly recall and rerun previously stored scripts.
How Do I Do That?
MSH scripts can be stored in simple text files with ...
Get Monad (AKA PowerShell) now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.