Friday, November 22, 2013

Microsoft Virtual Academy: PowerShell M02

Today I continue forward on my goal of completing Microsoft's Virtual Academy's PowerShell 3.0 training.
(http://www.microsoftvirtualacademy.com/training-courses/getting-started-with-powershell-3-0-jump-start?o=3276#?fbid=aVs9FfAH2DJ)
(rewritten based on my notes available here:
https://drive.google.com/file/d/0B1fwreWrAZioNW5OZzFLTmFHTzA/edit?usp=sharing)

Module 2 "The Help System"consists of 3 video segments totaling ≈ 50 minutes along with a PowerPoint of 10 slides.

The first 13 minutes are more of an overview of help in PowerShell v3 and older systems.  During this 13 minutes they cover how to update help, briefly explain the difference between get-help, help, and man and their biggest point learn to discover.

One of the biggest improvements to PowerShell v3 is the ability to update outside of product releases.  By using the cmdlet update-help PowerShell v3 will download current update files from the internet.  If your system is not internet connected you can use save-help from an internet connected system to save the help updates for offline update (http://technet.microsoft.com/en-us/library/hh849724.aspx). Now v2 doesn't support this feature but does have a way for you to ensure you view the most recent help information.  Simply add the parameter -online to your PowerShell v2 get-help statement:

  • get-help get-service -online
    • will open a browser window to must current help for that cmdlet


Next, they explain the difference between get-help, help and man (well help and man are the same just aliases).

  • Get-help
    • partial help file displayed
    • focus is at the end of the file, requiring you to scroll up to see everything
  • help / man
    • displays full help file
    • allows paging through the file one screen at a time
Lastly the biggest point to take away from Module 2 is learn to discover not memorize.  By learning how to use the help cmdlet you set yourself up to discover functions easier and quicker then trying to remember the thousands of cmdlets. There are over 96 verbs alone (get-verb | measure).

The remaining time is spent going over PowerShell syntax to include wildcards, how to navigate the CLI, reading a get-help and more.  One of the features they don't mention until near the end is the use of tab completion.  I feel this should be more towards the beginning as it is a huge time saver.  As you are type cmdlets you can press tab to cycle forward through matching cmdlets or shift-tab to cycle backwards. In addition to tab completion they mention using semi-colon (;) as a cmdlet separator allowing more then one cmdlet statement to be written at a time.  By now you may have already noticed some of the ways to navigate the CLI, such as moving left and right with the arrows but did you know you can recall past cmdlets by pressing up and cancel the current cmdlet by pressing ESC?

Now one of PowerShell's greatest features is the use of  wildcards (*).  Basically the asterisk (*) states allow anything before or after my location.

  • get-help *service*
    • returns all cmdlets with service anywhere in them
  • get-help g*service
    • returns any cmdlets the start with g and contain service within them
To further breakdown the help system they go into explaining the segments/sections of get-help: Name, Synopsis, Syntax, Description, Related links, and remarks.  I will let you check out the video for their descriptions of these.  Next they covered some of the parameters that can be used with get-help:

  • -detailed
    • more detail then just get-help
    • includes listing of cmdlet parameters and examples
  • -examples
    • displays just the cmdlets examples
  • -full
    • you guessed it this displays it all
  • -showwindow
    • new parameter in v3
    • opens a window displaying the cmdlet help information
    • can be configured to display only certain sections via the settings
    • great for copying and pasting syntax
    • over a find/search function to current displayed help file

Syntax explained?!?!
By now you have seen a few cmdlets using the get-help/help cmdlet.  What does all the information after the cmdlet mean/do.  Well they are call parameters and they allow the refining/altering of the cmdlet.   Simple enough right.  Well there is a certain format/order that these parameters may need to applied.

  • First there is the [ ] this one has two meanings depending on its placement
    1. At its top most level it means optional parameter.  This can be seen in most cmdlets as most parameters are enclosed in [ ].  But further review and you will find some cmdlets that over optional content within a parameter
      • [[-name] <string[]>]
        • This whole parameter is optional but if you choose to use it you can with out first calling -name and instead providing the string value
    2. Deeper is the defining of multiple values separated by commas
      • [[-name] <string[]>]
        • for the string value we could define: bob, rob, *ob
          • (Yes you can include wildcards)
  • Next there is the use of < > as you may have already noticed this typically denotes format the parameter is looking for arguments/values
    • string = alphanumeric
That concludes module 2. If you stop here you will already have placed yourself ahead of many other users.  Just remember to learn to discover.

1 comment:

  1. Short for Monestier-de-Clermont, an Alpine town near Grenoble, France, Moncler was founded in 1952 by René Ramillon as an outdoor-gear company, cheap moncler jackets moncler producing sleeping bags, tents, and other mountain-climbing necessities. Today, the French-Italian label is best known for its lightweight, super-warm quilted down jackets, cheap moncler trainers as well as ready-to-wear and accessories hardy enough to take on harsh winter weather.

    ReplyDelete