Powershell-thumb2[2] 

*** 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

 

“Everybody seated?   Got your Double cans of Jolt Cola?  Fluke Meters away?”

Good let’s get started.

So one sneaky thing we’ve learned about Developers is they LOVE punctuation marks.  It’s their secret language.  They do that so NOBODY (Not even another Developer) can understand what they’re saying.

That’s why they call it “CODE”.

No, no it isn’t.  I was pulling your leg 🙂

But we are goiing to introduce to a few tiny more bits in the “Syntax” (Still wondering where that guy from Guelph is!)

Much like previous bits, it’s….Wait….Wait…. This is the exciting bit! MORE PUNCTUATION MARKS! Wooooo Woooo!!!!

Actually it’s some square brackets.  One of the things you should know about Variables in Powershell is they are all Objects and more importantly they are all lists of information.  Some lists contain one item, some contain one million.  The trick is to know they are ALL lists.   To access them is easy.  You need to know two things.  A dynamic property called “Count” and how to use these [].

Here’s an example of what I mean

$THIS=’Something’

and

$THAT=GET-CHILDITEM

are the same.   Their contents may be different, the internal structure might be different but they are BOTH objects, and follow the same basic sets of rules.  Both will always have a property called “Count” (Which are the total Objects within the Variable, and Both can access their internal pieces using the [] and a number.

So if we do this.

$THIS.Count

Will give us the result of

1

Meaning there is one member in that list and to access that member we would type

$THIS[0]

to give us

Something

One of tricks is to remember than although humans start counting at 1 computers start Counting at Zero.  As such, the list starts at Zero.
Along the same terms I could type in

$THAT.Count

And get a result of

45

Meaning in THAT particular variable there are 45 entries.  So typing in

$THAT[23]

Might show us

Mode                      LastWriteTime Length Name
—- ————- —— —-
-a— 7/21/2009 6:26 PM 1422336 Somefile.xls

 

That’s really all there is to it.  There is more to Syntax but I think knowing some of the basics will help tremendously.   We’ll go back into it later more, but this at least gives you some more food for thought.

It also gives me time to restock the Jolt Cola supply.  The back section of the room cleaned me out. 🙂

Sean
The Energized Tech