Intro to Powershell, Part 1 - Commands

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. 1-27-2009-5-30-33-pm-0011

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. 1-27-2009-5-30-52-pm-0010

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. 1-27-2009-5-31-23-pm-0009

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. 1-27-2009-5-31-29-pm-0008

Aliases

Aliases are just a simpler, shorter name for a command. To get a list of aliases, just type the command get-alias. 1-27-2009-5-31-45-pm-0007

Now you can see a list of aliases, and what command they correspond to. 1-27-2009-5-31-50-pm-0006

Also, we can use the same pipeline trick to page the results. 1-27-2009-5-32-07-pm-0005

1-27-2009-5-32-15-pm-0004

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.

Just type get-help 1-27-2009-5-35-24-pm-0003

Now you have detailed usage instructions for the command. 1-27-2009-5-35-37-pm-0002

You can do the same thing for aliases. Type get-help . 1-27-2009-5-35-52-pm-0001

1-27-2009-5-36-10-pm-0000

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.