Reader writes: Where can server admins find good PowerShell training?

November 10, 2014 at 12:48 pm | Posted in Microsoft, Study hints, study tips, Technical Tips | 1 Comment
Tags: , ,

Editor’s Note: Regarding PowerShell and Passing the Microsoft 70-410 exam: one trainer’s perspective (Part 2), reader Jeremy Brown recently commented: “I feel there should be more sections in training materials dedicated to recapping PS… there is a disparity between expected knowledge and printed material…” Blog post guest author Scott Winger attempts to find some workable solutions.

For those of us who aren’t yet PowerShell Masters, Jeremy’s point is painfully sharp when one considers code snippets such as this one from SANS.org’s Cyber Defense & Cybersecurity blog:

[[[[[[[[[
filter extract-text ($RegularExpression) 
{ 
 select-string -inputobject $_ -pattern $regularexpression -allmatches | 
 select-object -expandproperty matches | 
 foreach { 
 if ($_.groups.count -le 1) { if ($_.value){ $_.value } } 
 else 
 { 
 $submatches = select-object -input $_ -expandproperty groups 
 $submatches[1..($submatches.count - 1)] | foreach { if ($_.value){ $_.value } } 
 } 
 }
}
Get-Service | ForEach `
{ 
 $sctxt = sc.exe qc $_.name
 $Path = $sctxt | extract-text -reg 'BINARY_PATH_NAME\W+\:[\W\"]+([^\"]+)'
 $Identity = $sctxt | extract-text -reg 'SERVICE_START_NAME\W+\:[\W\"]+([^\"]+)'
 Add-Member -InputObject $_ -NotePropertyName "Path" -NotePropertyValue $Path 
 Add-Member -InputObject $_ -NotePropertyName "Identity" -NotePropertyValue $Identity
 $_
} | format-list Name,DisplayName,Identity,Path
]]]]]]]]]

In this post, I’ll explain how you can teach yourself to analyze and create arbitrarily complex scripts, i.e., how to teach yourself to master PowerShell. But before starting, I want to share a little known droll fact: there’s an annual contest to see who can deliberately write the most impossibly abstruse code:

http://www.ioccc.org

Although this contest is for programs written in C, I’ve included it to show that countless others have wrestled with code that’s far too complex.

First, a few words in praise of PowerShell

Jeffery Snover, Parser, Syntax, Major Domo, Rom-Com.

At this moment you should be thinking:

[[[[[[[[
Rom-Com…

What?!

Good Golly man! … Is that a typo or are you drunk?
]]]]]]]]

Let’s take a look at these words a little more closely and then you can decide whether or not I need a 12-step program (or at least an editor) before blogging for a hapless audience.

Jeffery Snover:
He’s the guy who invented PowerShell. And, to give you an idea how important PowerShell is to your 70-410 endeavor, he’s also the Lead Architect for Windows Server 2012. So at this moment, you should be thinking, [[Holy SYNTAX DIAGRAM, Batman! If I’m gonna master Server 2012, I’d better learn PowerShell!]] This is absolutely true because, thanks to the vision of Mr. Snover, Server 2012 can be controlled, customized, queried, and tuned by over 2,400 PowerShell cmdlets.

Parser:
Precious few IT pros even know what a parser is, let alone recognize its quiet-yet-vital role in their success. But IT masters know parsers well. Whether you’re doing PowerShell, NSLookups, DiskPart.exe, or CMD.exe … heck, even when you’re clicking the mouse, it’s the parser that’s your Major Domo. It’s the parser that captures, interprets, and carries out your every syntactically correct command. So get to know PowerShell’s parser via the suggestions I’ve provided in the section below. And, then, practice, practice, practice.

Syntax:
Every language, spoken, written, mathematical, or musical, has a set of rules that its speakers have to know. And the rules for a language’s constructs are called its syntax. In the case of PowerShell, although at first you might be dazzled by its syntactical complexities, the mother of all PowerShell syntax diagrams fits on four printed pages. And this brings us to Rom-Com. You and PowerShell can do great things together. But, unlike two people in a cheesy romantic comedy who fall in love without speaking the same language, you and PowerShell won’t even get started if you don’t learn its syntax. So print and master the few pages of the PowerShell about_Command_Syntax file mentioned below.

Second, a curated list of resources and study tactics

Whenever one endeavors to learn a new programming language, a trip to the armory is a good first step, because you need learning resources.

Enter and explore the doorway to the Learning PowerShell Arsenal:
http://www.reddit.com/r/sysadmin/comments/2c2x22/best_place_to_learn_powershell/

Download the about_Command_Syntax document from Microsoft’s official PowerShell Syntax Authority. And I recommend that you keep it handy and refer to it often. (Here’s the link: http://technet.microsoft.com/en-us/library/hh847867.aspx)

Sign up for and become active on the Hey Scripting Guy PowerShell forum. Those of us who’ve been around long enough to remember the coveted, expensive, and hard-to-get IBM Red Books are astonished that this era’s IT experts are so helpful by tradition — and for free. Here’s the Hey Scripting Guy link: http://blogs.technet.com/b/heyscriptingguy/

Head over to YouTube and root out the many excellent PowerShell videos, such as this one from TechEd North America 2014:
https://www.youtube.com/watch?v=SSJot1ycM70

Study complex PowerShell code on your breaks and before bed.

And now for the big guns:  Buy Don Jones’ and Jeffery Hicks’ Learn Windows PowerShell 3 in a Month of Lunches. Lunch is optional, but the labs are not: do them as you work through each chapter.

[Editor’s note: I’m amending Scott’s post to second the reader’s recommendation of Windows PowerShell Best Practices by Hey Scripting Guy writer Ed Wilson, highlighted in a comment below.]

Third, the call to action

Fire up PowerShell and start with some “get” statements so you’ll do no harm. Then take your first baby steps using some simple “set” statements.

Then, start building your own custom library of scriptlets with commonly used categories, such as:

\Enumerating\ActiveDirectory,
\Enumerating\FileSystem,
\Parsing\TextFiles,
\Parsing\Strings,
\Parsing\TableData,
\Parsing\ObjectData,
\Writing\[same folders as parsing]
etc.

Proceed apace to Advanced Analytical PowerShelling:

Predict the results/output of PowerShell code that’s a step or two or even way beyond your current abilities. Then run the script and compare your guestimates to the results. Of course, for this type of practice, a computing sandbox in which you can unleash total annihilation is a must.

Correspond with experts by seeking out and participating in PowerShell special use case blogs, such as those at SANs Security and elsewhere:
http://cyber-defense.sans.org/blog/category/powershell

Look into the relationship PowerShell has with .NET and how you can use PowerShell underneath the graphical world of C#.

Take PowerShell to new unconquered worlds via Desired State Configuration Tool, Puppet Forge, and PowerCLI.

And here are some thoughts and words for those who would be PowerShell Mystics:

Study the notion of an Abstract Syntax Tree; diagram pieces of its underlying data structure on paper. Then celebrate as you come to understand how PowerShell’s Tab Completion feature works.

Study rudimentary Data Structures: Arrays, B-Trees, Heaps, Linked Lists, etc., because it’s the data structures that lie at the heart of all programming. Understanding underlying data structures is also, often, the key to troubleshooting complex IT problems.

If you’ve got comments I’d like to hear em.

And good luck with your 70-410,

Scott

P.s. If you’ve been wondering, [What’s up with the square brackets?]  Well, speaking of parsers, I had the good fortune of taking a Programming Languages and Compilers course at one of the world’s greatest Computer Science universities.  And when one writes a parser to carry out specific commands, one quickly absorbs the nature and value of brackets, braces, and parentheses.  So the brackets are this scrivener’s habit and they are what they seem: a simple delimiter for emphasis.

Editor’s note: today’s guest post was written by IT instructor Scott Winger. Scott is a computing technologist at the University of Wisconsin in Madison and a technical editor for VMware Press. He also teaches continuing education classes in IT for Madison College.


Entries and comments feeds.