*** 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
One of the things ITPros need to understand about Powershell is it’s ALL ABOUT OBJECTS!
Unlike many scripting languages that deal with Absolutes like “Arrrays” and “Strings” and “Numbers” Powershell is about as “Grey” (Or really Blue) as you can get.
I’m not going to pretend to understand all the deep spiritualness of Objects and OOP. Most days I’m lucky if I don’t kick the LAN cable out of the wall socket or don’t fall off my own seat. I’m an ITPro but first off I’m a disorganized Boob.
And OOP and Objects are very organized.
In the old world of Dos you had a simple thing called a Variable.
We all know what that is. Just a String. Letters. Simple.
Or Is it?
Look at it. We all know that it’s pointing to a Directory. And that Directories contain files. And that the files in the Directory are stored in a certain format (8.3) or LongFilename. We know that in particular that Directory is probably full of Batch files (Ok I’m guessing, It really could be full of TunaFish)
But my point is simple. We have just described an Object.
An Object is REALLY a Variable like we used to think, but a lot more (or sometimes a little) more descriptive. It says what information it has (Properties) or what we can DO to it (Methods). There are sometimes even Multiple Properties (like the Foldername, the date it was created on) and different Methods like Delete folder, Rename. There are many aspects to an Object.
But as ITPros we don’t need to be Experts on Objects to work with Powershell. We just need to have a little understanding of what they are. And accept that Powershell is actually passing, reading, writing, examining nothing but Objects.
Sometimes we look at piece of an Object (like the Filename from a File) or we deal with the Whole Object (A Directory Structure)
When you pipe a Commandlet into a GET-MEMBER, all you’re doing is saying “Show me all the pieces attached to this Object I can look, play or work with”
Here’s an example of simple Object, a Directory. When you type in
You will get this message (Presuming you have a folder called “Powershell” at the root of your C: Drive
And as always we can store that away in a Variable in Powershell. But it’s NOT a directory we’re looking at. It’s an OBJECT.
When you run that Object through a GET-MEMBER you’ll see the various Properties and Methods attached to that Object, like so
Although it gives us a large pile of goodies, most of the time we only see the Name (Name of the Directory), the Attributes (Read only, Archive etc) and the CreationTime.
But knowing there is MORE there if you need is part of the understanding of an Object. Understanding that it is Vague enough that just about every Powershell Commandlet will look at an OBJECT and work with just the pieces that it needs or understands is the Important bit.
And knowing that you can take out and use only the pieces you need AS you need them is half the battle.
You may now remove your “Peril Sensitive Sunglasses”, ITPros are safe to step back to normality and chewing on LAN Cables
The Energized Tech