Today, I decided that I didn’t like most of the Powershell intro articles and books out there. They focus a lot on semantics, details, language structure, and really complex use cases. But those are all orthogonal concerns. What really matters is what you can do with Powershell right now and what you need as a foundation. This is my attempt at creating a simple, light weight introduction to Powershell so that you can get started in minutes, not days.
Commands
For now, just think of Powershell as an updated DOS prompt, or even a Bash shell. Both of these have commands, and parameters to these commands. Powershell comes with a lot of built in commands that you can access as soon as you install it. For this article, I am going to focus on three commands, get-command, get-alias, and get-help. Once you understand these commands, you can start playing around with every other command Powershell ships with.
Let’s start with get-command. Just type it in the shell, and hit enter.
As you can see, this lists out all the commands that are currently loaded into Powershell, along with the type (which we will talk more about in future posts) and usage information.
Since this list is pretty long, you can pipeline the output into the more alias. Don’t worry if you don’t understand what these mean yet, we will get into the details in the future. Just type get-command | more and hit enter.
As you can see, this is similar behavior to the Unix more command, which allows you the page through the results instead of listing them out all at once.
Aliases
Aliases are just a simpler, shorter name for a command. To get a list of aliases, just type the command get-alias.
Now you can see a list of aliases, and what command they correspond to.
Also, we can use the same pipeline trick to page the results.
Help
I know what your thinking, what good are commands when I have no idea how they work. What the hell does Export-Console or Copy-Item mean? get-help command to the rescue.
Now you have detailed usage instructions for the command.
You can do the same thing for aliases. Type get-help
What next?
Hopefully this gives you a super simple starting point for learning all the commands in Powershell. Although you can’t do a lot, you can at least get started using it in 5 minutes.
As for what I am going to talk about in Part 2, I really don’t know. I was thinking the pipeline, variables, or even scripts and functions. Feel free to post any suggestions in the comments.