Tags


Powershell_thumb2 

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

Ok here all today ready to go. To learn you some more Developery stuff and make you ItPros fall deeply in Love with Code and Make love to .NET.

No? Did I overstate my case? Did I at least get your attention?

Good.  That was my only intent.   If you thought anything else, well errr… You know I just don’t have an answer to that except “Sorry”

We’re going to touch on a little more Syntax…

No you, We’re not going to “Touch that Guy in Guelph” he might hit us back.  No “Syntax” the language (Where did I GET these students?)

One of the biggest and most powerful items in the Syntax of Powershell is this

 

.

 

If you missed it, it’s just a little “Dot”, “Period”, “Decimal” or “Piece of Dirt on the Screen”

Knowing this opens up Pandora’s box.   Why?

It is the Connection between Objects and Methods and Objects and Properties.  It is how you make the link between the two.

It is also important to know that it just doesn’t stop at “one connection”.  Here’s an example

$THIS=’REALLY IMPORTANT STUFF’

We have an OBJECT with some characters

$THIS.substring(17)

Pulls up

Stuff

But it doesn’t stop there.   Each time you add on something to an Object it becomes a new slightly different Object.  With it’s own Members.  And like LEGO (Oh no!  LEGO LAWYERS RUUUUNNN!!!) you can keep adding on my pieces.

So if we were to do this.

$THIS.substring(17).toUpper().padright(30,”!”)

We get this

STUFF!!!!!!!!!!!!!!!!!!!!!!!!!

Because each Property and Method can link down and down and down all because of that darn little Dot.  We took  the $THIS Object and tacked on one Method, and a different Method based upon the Properties of the new Members.  Yet even a third Method beyond this.

Another cool trick is knowing all about the “TAB” key (which for some darn reason won’t appear when I type it, keeps moving across the Blog page)

Tab does a LOT of what our Developer friends call “Autocomplete”  You’ve seen it in the Command prompt.   Because like us, they HATE typing. So in Powershell they added Autocomplete.  

Sometimes (or very often) what you can do is Powershell is start typing a Commandlet, hit “TAB” and it will COMPLETE your typing for you.  Same with the Parameters. If you type in a “-“ (Hyphen, Minus Sign, Stick) after GET-CHILDITEM or any other Commandlet you will see it prompt you with available parameters.

Repeatedly hitting the Tab Key will loop through the list.

And it’s the same with when you put the magic “Period” down.   Sometimes Powershell can “look inside” and show you what options you can work with.

If you ever get into using the MSDN and .NET library Directly, you’ll find these Autocompletes can unlock secrets sometimes not even coded as CommandLets by Powershell.

Ok I can the rest of the ItPros glazing over, it’s time to step out.  But let this mold into your mind before your mind turns to mold.

And would somebody wake up the back row?

Sean
The Energized Tech

Advertisements