Chapter 4. Running commands

When you start looking at PowerShell examples on the internet, it’s easy to get the impression that PowerShell is some kind of .NET Framework–based scripting or programming language. Our fellow Microsoft Most Valuable Professional (MVP) award recipients, and hundreds of other PowerShell users, are pretty serious geeks who like to dig deep into the shell to see what we can make it do. But almost all of us began right where this chapter starts: running commands. That’s what you’ll be doing in this chapter: not scripting, not programming, but running commands and command-line utilities.

4.1. Not scripting, but running commands

PowerShell, as its name indicates, is a shell. It’s similar to the Cmd.exe command-line shell that you’ve probably used previously, and it’s even similar to the good old MS-DOS shell that shipped with the first PCs back in the 1980s. It has a strong resemblance to the UNIX shells, such as Bash, from the late 1980s, or even the original UNIX Bourne shell, introduced in the late 1970s. PowerShell is much more modern, but in the end, PowerShell isn’t a scripting language in the way VBScript or KiXtart were.

4.2. The anatomy of a command

4.3. The cmdlet naming convention

4.4. Aliases: nicknames for commands

4.5. Taking shortcuts

4.6. Cheating a bit: Show-Command

4.7. Support for external commands

4.8. Dealing with errors

4.9. Common points of confusion

4.10. Lab