Getting Started with PowerShell 2.0

Hi All,

In this blog I would like to just pass along a few tips that will make your life easier when getting started with PowerShell.

Opening PowerShell as Administrator without ever touching the mouse on Windows 7 or Server 2008 R2

  1. Press the “Windows” key to open the start menu.
  2. Once the start menu is open, begin typing the word “PowerShell” in the search box until it comes up as the selected item on the menu.
  3. To select PowerShell from the menu, hold down ctrl+shift and press “Enter”.
  4. When prompted by UAC select “Yes” by holding down the “alt” key and pressing “Y”.

Now the PowerShell Command Prompt should be open and the Title Bar should read “Administrator: Windows PowerShell” to show that you in fact have opened it as administrator.

How to get a list of commands inside PowerShell

Now that I’m in PowerShell, what do I type?

To get a list of commands just type “Get-Command” and press “Enter”. You will now long list of commands that can be used.

You will notice as shown in the screenshot above, you are not able to read all of the descriptions. To solve that problem you can type “Get-Command | Format-List” or “Get-Command | fl” to format the list.

Now you will notice that you may have received too much output or its jumping by on the screen so fast you can not read it.  Also, once it completes you can not scroll back up far enough to see everything. To prevent your head from spinning due to the output of this command simply append a “| more” to the end of it so I can control how fast the data is being output. The command would be as follows:

“Get-Command | fl | more”

Ok. Now I’ve formatted the list but I don’t need to see all of this information right now. I just wanted to see the “Name” and the “Definition” as well as have the ability to read it all. To do this you could simply type “Get-Command | fl Name,Definition”.

Getting Help in PowerShell

Now that I have sifted thru all of these nifty commands and definitions I have found one that peaks interest but I dont know how to use. Its time for me to ask for help. To get help for any cmdlet you can simply type “Get-Help cmdletname(cmdletname=the name of the cmdlet that peaks your interest). For example, to get help for the “Get-Process” cmdlet you would type “Get-Help Get-Process” as shown in the screenshot below. This command will give you the general help you need to use this cmdlet. As you can see in the “Remarks” section of the screenshot below, you have the option to type “Get-Help Get-Process -examples”, “Get-Help Get-Process -detailed” or “Get-Help Get-Process -full” depending on what kind of help you need.

Now that you know how to get a list commands as well as how to get the help to use them, you can begin experimenting and build from there. In my opinion, it is a good idea to learn with cmdlets that retrieve information (for example “Get-Process”) when first getting started so you don’t accidentally change anything you didn’t intend too. As always, using a lab environment is the safest way to learn and test anything.


Related Links:

Recording the Commands and Output of a PowerShell Session to a text file in PowerShell 2.0

Using the Show-Command cmdlet in PowerShell 3.0

Using the Server Manager Module in PowerShell to Install Roles and Features On a Windows Server

Leave a Reply

Your email address will not be published. Required fields are marked *