Monday, November 25, 2013

Microsoft Virtual Academy: PowerShell M03

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

Module 3 "The Pipeline"consists of 3 video segments totaling ≈ 30 minutes along with two PowerPoints of 12 and 10 slides.

This module was short and sweet, teasing you with the power of Powershell while also showing you how to protect yourself from destroying your system OS.

To start of the module we learn what is the pipeline (|) which if you are wondering is the key above the enter on keyboard (shift + \).   Now what is the benefit of the pipeline in Powershell, well is allows the connecting of cmdlets to accomplish a larger task. In the simplest form it passes the results of one cmdlet to an other to be processed.

  • get-service -name bits | stop-service   is the same as    stop-service -name bits
Now this is the simplest form and may be hard to see the benefit in above case but it is just for reference. Now as you notice with the above example couldn't I just send all services to stop and yes you could, though you would in essence be crippling/bricking your system as Powershell by default acts on all commands without questioning you.  This is were the last part covered is important.  Powershell provides ways to safeguard yourself with -whatif and -confirm.
  • -whatif can be added to almost every cmdlet statement to see output results of the cmdlet without actually executing it
  • -confirm will prompt you if you wish to execute (take note of Yes, Yes to all, No, Not to all)
One of the huge benefits brought to light in this module is auto loading of modules which was not possible pre-v3.  In addition to PowerShell v3 auto loading modules for you it also has a complete understanding of the modules help (requirement is module must be installed on the system).  In pre-v3 you had to mount a snap-in before you could use the cmdlets or even have help understand them.  This is a huge time saver and will reduce frustration. 

Lastly they touched on features of exporting, importing and some comparing. They didn't go into to much detail as they will be covering this later in the series.
  • Export to many popular formats
    • csv, xml
  • Import files back in for processing
  • Ability to compare file to running system
    • In the module they demonstrated making a known good xml file of system process and then comparing to another system
    • Great way to see what has changed from baseline of systems
    • I will be creating baselines for all system types when I re-image next time for future troubleshooting 
      • Get-process | export-clixml –path C:\good.xml
        • creates the xml
      •  Compare-Object -ReferenceObject (Import-Clixml C:\good.xml) -DifferenceObject (Get-Process) -Property name
        • compares the baseline created before to current running process names
Until next week.

No comments:

Post a Comment