Monday, December 2, 2013

Microsoft Virtual Academy: PowerShell M04

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/0B1fwreWrAZioVFozYmprdHJGT3c/edit?usp=sharing)

Module 4 "Objects for the Admin" consists of 3 video segments totaling ≈ 50 minutes along with a PowerPoint of 13 slides.

Focus on this module is Objects (just as the title states, huh weird).

First off we learn what an object is and how it makes our lives easier in PowerShell.

  • Object
    • has properties
      • things we can view about the object
    • has methods
      • things we can do to the object
Now that we know what an object is how can we see what properties, methods, etc it has.   Well this is where they give us a powerful cmdlet: get-member (gm).  By using the pipeline to send an object through Get-Member PowerShell spits out data providing all the details.  Some key areas to pay attention to are:
  • ObjectType
    • Tells us what type of object we are viewing, import in later modules
  • MemberType
    • Displays all the properties, methods, etc
An interesting segment of the module was importing third party xml file and showing how easily PowerShell can manipulate and pull data from it.
  • Demo of Romeo and Juliet XML play, truly a powerful example of PowerShell
Introduction to filtering and limiting within PowerShell with the use of Select and Where.
  • Select-Object (Select)
    • By piping a cmdlet to Select you can limit what is displayed
      • get-process | Select -Property name, ID
  • Where-Object (where)
    • 2 version
      • Most powerful and versatile uses filterscript {} ({ })
        • assigns current object to variable ($_ or $PSItem)
        • evaluates the code (comparison operators)
          • More details on comparison operators or operators use get-help about_operators
        • acts on results
          • true passing it forward
          • false thrown away
      • Simpler is just the where
        • where property operator value
        • where name -like wmi*
    •  

During their responses to Q&A we learn that for the most part PowerShell v3 is case insensitive when it can, usually third party modules. 


References mentioned in this module:

  • PowerShell.org
    • Forums, FREE eBOOKs, articles, podcasts, script repository
  • Learn Windows PowerShell 3 in a Month of Lunches
    • Don Jones
    • Chapter 9


No comments:

Post a Comment