Powershell-thumb 

*** WARNING! ***
*** This Blog Post will talk about Developer Terms ***
*** ItPros are cautioned to break out their (Patent Pending) ***
*** “Peril Sensitive Sunglasses” (Ala the HitchHikers’ Guide to the Galaxy) ***
*** Before Reading further. If you are amongst the Bold and the DARING and the ***
*** Truly Devil May Care of ITPros, Please feel free to Read on and live Daring! ***

But don’t say I didn’t warn you 🙂
Sean – The Energized Tech

Now for today’s session I’ve got a whole crate of Jolt Cola to kee….

Ok.

By the glazed and buzzing look in your eyes I HAD a whole crate of Jolt Cola to keep you all awake.  That’s fine because you’re going to need it.

We’re going to talk “Syntax” today.  

Syntax is not some cool guy talking about Coffee and Code in Guelph (he is) but it is the Structure, the rules of the language within Powershell

You already know some of it without realizing it.  You already know that Powershell use a “Verb-Noun” structure for all of it’s Commandlets

GET-CHILDITEM

WRITE-HOST

ERASE-SERVERFILESYSTEMANDRUNAWAY

Ok I made up that last one to see how away you were, but that’s a big piece.

You already know as well that placing a “$” with a name gives you a variable to hold objects just like this.  And it can hold anything since it’s all just OBJECTS.

$THIS=’Something’

$THAT=GET-CHILDITEM

You also should know this that ANYTHING between two Parentheses is a Block of code, like this

{

$LIST=GET-CHILDITEM
$LIST | REMOVE-ITEM –whatif

}

And anything inside a pair of Round brackets usually contains information or a parameter to precede something, or possible (just like in Math) something to isolate the equation

IF ( $THIS –eq NULL) { $SEANISINALOTOFTROUBLE=$TRUE }

$STUFF=GET-CHILDITEM –RECURSE
FOREACH ( $ITEM in $STUFF ) { WRITE-HOST $ITEM }

IF ((($THIS –eq $TRUE) –and ($THAT –eq ‘Something’)) –or ($THATOTHERTHING+1 –gt $THEOTHERIMPORTANTTHING)) { WRITE-HOST ‘Mommy!’ }

Some of this may be review to you, some of it may be new. 

My goal over the next while with these blog posts is not to make you an EXPERT in Powershell but hopefully give you the Power to understand enough of the pieces to read scripts and maybe build your own. 

We’ll continue more next time when I’ll be back with a little more Syntax and a lot more Jolt Cola.  And maybe a little C4 😉

Sean
The Energized Tech