March 2010 Archives


The keyboard is covered in sweat, there is heavy breathing in front of the screen.  “Quick disconnect the LAN cable before she finds out!”

“Dear Diary.

I should be ashamed.   I am having an affair with vbScript and my Mistress Powershell suspects something is up.   There were a few times this week I accidentally used a ‘ instead of a # to comment.   This is getting dangerous…”


And so I promised.  Today we’re going to get Loopy and see a vbScript loop vs a Powershell loop to make the task of converting easier.   For although many of us love working in Powershell, we must tip our hats in respect to vbScript and it’s amazing established library.

Having said that, we shall RAID and PILLAGE for code to rewrite… “Yeeeaaarrrrrhh!  AHAR!”

So a quick look and one of the most common loops is the For Next where you establish a range of information to step through, going FOR the NEXT one as you encounter it, and well do SOMETHING.

in the magical Land of vbscript here is a very basic looking “For” loop.

For This = 1 to 20

wscript.echo This


in Powershell that would look like this

FOREACH ( $THIS in 1..20) {



There are some SLIGHT differences in the Syntax ( Parentheses about the code in Powershell for one ) but if you look at each, they are very similar.   They both specify a Range of values and simply execute a block of Code.   VbScript requires the “Next” indicate the end of it’s particular FOR loop but the functionality is very similar.

Here’s where the two are VERY much the same (and thus where translation becomes a little bit easier)

Here is a script borrowed from the TechNet Archives (Free to download) which simply lists the Services on a PC

strComputer = "."

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colRunningServices = objWMIService.ExecQuery("Select * from Win32_Service")
For Each objService in colRunningServices 
Wscript.Echo objService.DisplayName & VbTab & objService.State

My first reaction was “AIHAGHAIHGHAIHGHAHGHAHHG!!!!” with my hands flailing in the air in panic.

Then I looked at that last bit. That looked SUSPICIOUSLY like I was staring at

FOREACH ($ObjService in $ColRunningServices) { Do stuff }

That’s because I was. vbScript can deal with Objects too (not quite as elegantly as Powershell but it can.  Understanding this helps you see a loop like that and realize some of the code is VERY similar

So that same code from vbScript translated to Powershell could look like this


$colRunningServices=GET-WMIOBJECT -namespace ‘root/CIMV2’ –query ‘Select * from Win32_Service’

ForEach ($objService in $colRunningServices) {

  Write-host $objService.DisplayName, $objService.State

Ok the format isn’t EXACTLY the same but this session is about LOOPS. And if you stand back and pause, you’ll see the slight differences and also the similarities between the two loops.

And that’s not really all that difficult to translate between the two.  It’s just about the Syntax.  So next time we’ll see the other loops and hopefully not get TOO loopy and lose our minds.


Just Remember, The Power of Shell is in YOU

The Energized Tech


An interesting task to go about today.

“How do I tell if a User has rights to another user’s Mailbox?”

In Exchange 2007, in the new Console, an Enterprise Exchange Admin can now EASILY grant FullAccess and SendAs rights to users.

the problem comes up that after a few years, well you’re going to wonder WHO is able to access WHAT?   Especially with staff changes and Administrator switches.

But thankfully with Powershell, this is a Breeze!

We have a commandlet called GET-MAILBOXPERMISSION.  It ties right into GET-MAILBOX too.

So watch this little trick.

GET-MAILBOX john.smith | GET-MAILBOXPERMISSION | where { $_.Name –like ‘*Joey.Admin*’ }

That one line will tell you if “Joey.Admin” has rights (any rights) on John.Smith’s mailbox.

Now it gets cooler.  Maybe “Joey.Admin” got fired and we need to make sure he doesn’t have access to other mailboxes.  Or better yet.  Perhaps “Joey.Admin” didn’t LISTEN to his boss and was casually granting himself full access to corporate mailboxes abusing his admin rights.

Wouldn’t you like to EASILY know?

Same command but don’t get specific

GET-MAILBOX | GET-MAILBOXPERMISSION | where { $_.Name –like ‘*Joey.Admin*’ } | Select-Object $Identity

Now you have all the Mailboxes “Joey.Admin” had rights on (even if he wasn’t SUPPOSED to have rights on them)

Fine.  So we figured out the mess Joey left.   Wouldn’t it be nice if there was an EASY way to clean it up after we Demote Joey to Janitor?

Piece of cake in Powershell

GET-MAILBOX | GET-MAILBOXPERMISSION | where { $_.Name –like ‘*Joey.Admin*’ } | REMOVE-MAILBOXPERMISSION –user ‘DOMAIN\Joey.Admin’ –inheritancetype ‘All’ –AccessRights ‘FullAccess’


I agree that’s a mouthful to type, but that will go through the list and prompt you to remove Joey.Admin from the permissions.  If you want to have him removed from all those mailboxes, just choose “Yes to All” when prompted. 

This will work for anywhere from 1 to however many mailboxes you have.  All in one line.

The Power of Shell is in YOU

The Energized Tech


A colleague contacted me yesterday. 

He said “Oh Great and Wonderful Wizard of the Shell, bequeath to the me the guidance to navigate the mystery that is Powershell so that I can easily produce a report of just WHO is in my Groups…”

Well no, he didn’t say it QUITE that way.  It was more, “Sean, you know Powershell, can we easily pull out a report, something in CSV or Excel that show’s members of Groups in Active Directory?”

The only tricky part about that question was this.  “Would you like that in one line or two?”

In truth, thanks to the new Active Directory Modules in Server 2008R2, life for the new Network Administrator in the Enterprise just got so much better thanks to GET-ADGROUPMEMBER

All you need to do to list members of a Group in Active Directory is


Done.   So You need to audit your Domain Admins or Enterprise Admins?  Piece of cake!


GET-ADGROUPMEMBER ‘Enterprise Admins’

How about a custom group you made called “Uber Secret Stuff We Won’t Share”?

You guessed it

GET-ADGROUPMEMBER ‘Uber Secret Stuff We Won’t Share’

Need that in something Excel can use?

GET-ADGROUPMEMBER ‘Domain Admins’ | EXPORT-CSV C:\ListOfPeople.csv

Now of course this may pull down too much information.   Generally we just want some basic details, Like Name, SAM Account, Possibly the DN.  Patch in a SELECT-OBJECT (which allows you to “SELECT” which “OBJECTs” you want from the PIPELINE from the previous CommandLet.   Then pass it along or view it.

GET-ADGROUPMEMBER ‘Domain Admins’ | SELECT-OBJECT Name, DistinguishedName, SamAccountName | EXPORT-CSV C:\ListofPeople.csv

Now this is all fine, but I prefer making this into a useful Function I can add to my $PROFILE.  So let’s do that.   Instead of typing in all this, let’s make this into a Function that could be reused easily

function global:GET-GROUPAUDIT($GroupName, $Directory) {

# Check for Directory name.   If not given Default to the C:\Reports folder
if ($Directory –eq $NULL) { $Directory=’C:\Reports’ }
# Build $Filename for output.  Strip spaces from GroupNames for the
# Filename.   Add Default Directory to Path
$Filename=$Directory+”\”+$Groupname.Replace(‘ ‘,’’)+”.csv”
# Run GET-ADGROUPMEMBER in the default domain, Select three Objects
# Name, DistinguishedName, SamAccountName
# Export the results to a CSV file
GET-ADGROUPMEMBER $GroupName | SELECT-OBJECT Name, DistinguishedName, SamAccountName | EXPORT-CSV $Filename


Now this is a very basic function that “Assumes” you’re goinig to type in the Group name and the Directory.   But what it means if you need to report this on a regular basis?  Add that function to your $PROFILE, then in your Powershell Session you can type in

GET-GROUPAUDIT ‘DomainAdmins’ C:\Reports

Or easily just pipe in a list of Groups to Query on a regular basis.   This Function has also been setup to do two slightly smart things.  One it will at least ASSUME a folder called C:\Reports if you don’t type it in.  Second it will create a .CSV file matching each Group Name.

There you have it.   It wasn’t hard to play with with and even easier to build on!

The Power of Shell is in YOU

The Energized Tech


I’ve been listening to a LOT of “Green Day” lately and this one tune from “American Idiot” keeps hitting the top of the list on my cheap MP3 player. 

So I rewrote it :)

Original Song - “Are We the Waiting” from “Green Day” redone as

“We are the Scripters”

Part 1 - vbScript

Quiet Times
Parsing Lines
Floating down like a dream

Brain Unfurled
An Ascii World
On my Screen

(Repeat 2x)
Are we
We are

The Scripters Alone

We automate
Setting free

The systems and
Data stores
that You see

We're shouting!

(Repeat 2x)
Are we
We are

The Scripters

We're shouting!

(Repeat 2x)
Are we
We are

The Scripters

Dim Constants
Quiet Chants
As I script in VB

Tiny Code
Brain Overload
Not in C

(Repeat 2x)
Are we
We are

The Scripters Alone

We monitor all
The systems tall
That you see

Our Data is
Protected by

(Repeat 5x)

Are we
We are

Are we
We are
The Scripters

Part 2 – Powershell

Lord Jeffrey burst on out
a Blueness in his hands

Gleam shining in his eyes,
casting out among the lands

Know what your gonna Get?

Big Bag of CommandLets.

Launching quickly OUT-HOST


My name is Jeffrey
And I'm casting out my code
A system full of Power that will make your head explode

A simple Verb-Noun combo
And a little Dotnet

You'll Feel the Power of Shell with a single Commandlet

With a single Function and Profile
Throw in a snapin
take you down a mile!

I've Got myself that PowerGUI
I've got that Quest A/D
And if that is way too hard
I've got an ISE

I'll just Pipe those Objects
Right on down the line
I'm cruisin' away in Powershell
There's no Stoppin' sign

With a single Function and Profile
Throw in a snapin take you down a mile!

Part 3 – Saint Jeffrey

My name is Saint Jeffrey
I'm the Lord of the Shell
Patron Saint of the ItPros

I release out unto thee
What thy hath decreed
To be a way
that to vaquish thy Foes

No more vbScriptin'
And no more of the batch
Just a way we can unify

All of our solutions
Community Contributions
To launch us to the Azure Sky

It's Powershell
It's here for me
It's Powershell
It set us Free!


"Today’s article in Powershell is brought to you by the letter ‘P’ with Commentary from the “#” character.

This seems so lame to talk about but I think one of the simpler things to understand in Powershell was the simple concept that any line preceded by a “#” was just a comment, Words left by the Author.   Knowing that made it easier to read scripts and ignore certain information. 

vbScript has comments too.  No shock on that one.  They are similar to Powershell comments, ending with a hard return; but beginning with a lowly quote like this


Why do you even care what a Comment is? 

If you’re new to coding and scripting it is sometimes those little nuggets the author left behind to tell just WHAT was going on in their head.  Comments are sometimes that tiny FAQ sitting inside the script.   Instructions.

Understanding what a comment looks like ALSO helps simplify translation.  I say this because often what I have found is going from vbScript to Powershell that some code is beautifully commented.   So much so, that I can’t understand what is actually going on.  

As important as they are, it’s also equally as important sometimes to remove the verbal static that IS comments from the flow of a script for me to understand it.

Here is an example

--------------- Script End -------------------------

‘ Sample script designed by Sean Kearney to demonstrate
’ TOO many comments in a vbScript to confuse
’ poor Powershell noobs and give headaches to the
’ the many people reading this blog
’ as each one of these lines contains a comment, sometimes TOO many
’ comments and placed in the Wrong spot make it difficult to read
on error resume Next
‘ the code which is not what a comment should do.  Oh shouldn’t I have
’ mentioned that the previous line was to control errors?  Oh nuts.  This
’ is why I don’t code for a living.   There is a constant coming up here
HelloMessage = "Hello I am a message"
‘ There it was!  Wow! what a lame thing to do, throwing a constant in
’ the way of my flow of typing.   I’m feeling a bit loopy now.  OH speaking of
‘ loops.  I think I was going to execute a loop for some reason.  Of course there
’ was a reason I was doing all of this
For A = 1 To 20
’ Oh yes.  Right.  I was going to show the readers not only an example of bad
’ Commenting but also how sometimes the code get’s lost in the comments
    WScript.Echo A & HelloMessage
’ And as a result it CAN be hard to understand what the program was doing
‘ so that we could translate it to Powershell

--------------- Script End -------------------------

Ok I’ll admin this is a HORRIBLE script with even worse comments, a trained Gerbil could have done better.  But it is only to serve one purpose.   For you to see how to see what a comment IS in vbScript and mostly to have a little fun.

The same script without all the jibbierish is

--------------- Script End -------------------------

on error resume Next
HelloMessage = "Hello I am a message"
for A = 1 to 20
   wscript.echo A & HelloMessage

--------------- Script End -------------------------

What purpose did this serve? 

Just a little more understanding of the Syntax that is vbScript if you need to translate to Powershell.   And possibly a way to understand how to filter out that “extra stuff” when you’re just trying to see the flow of the logic.

Next time we’re going to go loopy.  Yes.  Loops in vbScript vs. Powershell.

the Energized Tech


Yes.  I am speaking vbScript in a blog that is Dominantly Powershell.  

Now all of you put down the burning torches, Rocks, Llamas and sacks of wet Cheetos.  There is no need for a mob scene.

We’re going to talk a little bit about vbScript (just a bit of Syntax) for Powershell people because there are a LOT of WMI based vbScript solutions out there.  Heck there are a TON of vbScript solutions out there.    It pays to remember a lot of brilliant people devised these solutions and their knowledge should not be ignored.

So you’re a Powershell guy and you’re trying to make a new “wheel”.  There are some things that are just so simple in Powershell, we don’t even think about looking further.

Then there are times (especially if you’re learning Powershell) you try to find a solution, all you can find is vbScript.   Well then. Translate that to Powershell!

Let’s look at a simple vbScript statement


Well if you’re working in Powershell that’s the same as doing a


But often in Powershell setting a permanent Global constant isn’t as necessary and we just do a


As well in vbScript you’ll often see a statement like this

SET FolderName=”C:\Windows

In Powershell it’s a slight switch in Syntax


Really not such a huge headache to deal with.   Now one of the things I ran in to in vBscript were stuff like this


I originally couldn’t make heads or tales of this.  THIS was a ‘secret code’ in my world.  Well no, no it wasn’t.

It was a HexaDecimal number.   The two ‘& &’ are Delimiters in vbScript to indicate where this special non Decimal number starts and ends.   The “H” immediately after indicates the sequence of characters are a Hexadecimal number using the characters from 0 to F. Until it reaches the second ‘&’ this is a Hexadecimal number

Powershell, typing in such numbers is (I think personally) a little more direct.

0xHexadecimal number

So looking at


In Powershell would be


We’ll look at a little bit more vbScript next time.  Just a bit.

Remember just because you love Powershell doesn’t mean you should scorn vbScript.   Embrace the knowledge from those before you and learn IT to shape the future.

The Energized Tech


Powershell.  Powershell.  Powershell.

I do it all in Powershell.

So that means before Powershell was here NOTHING happened right?  There were no automation solutions, Administrators sat down with gnawing on LAN cables to lower the stress levels.  CoOp students would hide helplessly in their cubicles waiting for the next onslaught of insanity as Administrators lost their cool with No way to interface with the system.



Before Powershell there was vbScript.   vbScript is more complex than Powershell I find personally but it works.  It works well.  There’s just sometimes a lot more code involved.

But I prefer to stick to one solution.  For one reason.  Consistency.  I can keep all my tools under one type of code.  And in the newer environments like Exchange 2010 and Server 2008R2, they leverage Powershell scripts heavily.  Keeping all my automation solutions under this umbrella makes things easier to interface.

So sometimes I have to find an answer to a problem.  The answer no matter how many times I “Bing It”, search, pray to Juju, or sacrifice a CoOp student; is in vbScript.  Because that code has been roaming about a LOT longer than Powershell and has a bigger base.

But here’s a trick I learned.  Learn to SPEAK vbScript a little.  Not necessarily to Code in it but to understand it’s Syntax a little.   It helps.  I have found numerous scripts in vbScript for Accessing ADSI, WMI out there.    I can code them in Powershell; sometimes in fewer lines.

So over the next few articles, we’re going to learn a new trick.  We’re all going to be Bilingual in Powershell in vbScript (if even just a bit)

The Energized Tech


The Powershell environment offers up something truly unique I think.  The concept of what “Shellers” call the “One Liner”

It is truly a geeky thing to behold to see a well written one too.

People new to Powershell may not initially quite grasp just WHY you’d bother with such a thing.   It goes back to that whole concept of “Instant Gratification” in Powershell.

You see, you can type in line by line and test things.  On that particular piece of code.  But to test a BLOCK of things or trying to see what those objects have really can’t happen until “Script Execution time” or unless you begin to the learn the art of the “one liner”.

All a “One Liner” is, is the content of a script written and composed using the most DIRECT form you can.  Let’s go backwards.  Let’s see a script first in normal mode and then as a single line


      WRITE-HOST $ITEM.NAME ‘is an Old file’
      WRITE-HOST ‘-----------‘


A pretty simple script that looks in the “Stuff” folder for … well stuff that is older than 30 days and lists it.

Now let’s “condense” the lines in the “IF” statement by separate lines instead and remove all the returns




See ?  The CODE is still the same but all we’ve done is place a “;” for each line where Code statement would have ended.  Now we’ll go further and remove the blank space between the “{ }”


Look carefully.  This is STILL the same code.  We’ve removed the FORMATTING but this is still the same code.   Now let’s jump one more level and remove the Line breaks for the rest of the lines.


Ok this is definiitely a lot harder on the eyes, but if you look carefully, the “;” have replaced the line breaks from before.  That’s because they both serve as a “Delimiter” which is one of those funky Developer words that mean “STOP HERE!”

And now to get really “l33t” on this One Liner, we’ll remove the variables where we don’t REALLY need them and shorten what we can.


Ok, yes hard on the eyes.  not really more efficient.  But if you understand the format of how you CAN execute an entire shell in one line, then sometimes you can use Powershell to quickly AdHoc query information, composing quick little scripts.

Sometimes just to see if it will work. :)

Powershell, One Liners there for you

The Energized Tech

This might be old news, but I don’t think so.  I wandered into the Local Future Shop here in Canada.

$499.   The numbers stared out making me blink twice.

Multitouch Monitors from Acer approximately 22” are OUT and READY for Windows 7.  

I don’t mean a WHOLE computer.  I mean better.

Take your EXISTING computer, add Windows 7 to it (unless you already have it) and Just buy ONE single 22” display to replace your existing monitor.


You now have a MultiTouch PC.  An AFFORDABLE MultiTouch computer.  Built the way you like it.

Running an office?  Like to spice up the Front Desk?  Throw a MultiTouch display in there to catch the attention of your clientelle.   This is no longer StarTrek technology, this is no longer out of of reach or untouchable.

In fact it is VERY touchable both in physical contact and Price range.

$500?  HELL YES! I’m getting one next check!  SCREW RENT! :)

The Energized Tech


We have had other management technologies in the past, various tools in dos, vbScript, GUI tools.  They all work.

But why this drive to Powershell?

Where Powershell I think personally wins over EVERY existing solution we’ve ever had for the following reasons.


Rather than trying to leverage a solution using a 3rd party utility, various Command Prompt tools and vbScript; then getting them to talk to each other.   I can now use one structure, one syntax, one Environment to perform 99% of my work. 

.NET Enabled

Since Powershell leverages and swims through .NET like a little kid in a Cookie jar, it has unlocked the biggest box of electronic goodies ever.   All of the Office Collections, abilities to communicate with Windows Explorer, Libraries are now at our fingertips.   vbScript had this too, but going back to the first point, Powershell is INTERACTIVE.   So you can now try something immediately and success or fail in that task quicker.


Probably the best feature of Powershell is it is so incredibly easy to add on features.  If the feature you have ISN’T native, you can often leverage technology within Powershell to make that solution as a Function.   This allows you to manage technology in Powershell that may not presently have a Commandlet (like Office Communications Server 2007R2)


If you are a Developer, you can easily make a simple commandlet for an Administrator to manage a feature of your system WITHOUT building a big Management gui.  Time saved.  If you are an ITPro you can write code to automate your systems and interface with web based management interfaces without dragging in developers. 


Powershell doesn’t simply have the backing of Microsoft, it has the backing of the Community.  IT Professionals and Developers; people just like you doing the daily battles against Digital Daemons.   There is a unstoppable force helping to grow and shape this technology completely independent of Microsoft.


Just like on the old home computers, when you type something in on the screen you IMMEIDATELY got a response.   That is the single biggest strength in Powershell.  I can execute a single line of code and without hesitation get the results of that output.   Previous solutions required the editing of scripts with notepad, saving, executing, cursing, repeating the process.

There i’ve said my peace.  Now if you work well in vbScript or other tools?  Don’t stop and drop what you’re doing just to ONLY do it in Powershell.

But remember there is another tool available to you now.

…And it is unbelievably POWERful

The Energized Tech

\Had to help out some friends at Around the Clock I.T. Solutions Inc. tonight.  An interesting problem.

A server that was running a Software mirror had the mirror broken for repairs.   Several reboots later all was good. 

Server decided after a reboot to produce this wonderful nugget.

Error in C:\BOOT\BCD


In general a BCD error.   But the BCD was intact.  To make matters worse the SBS 2008 did not natively recognize the file system and after adding drivers from the Windows Recovery Environment.   Adding drivers afterwards, the O/S appeared to be not there.   But all WAS intact.

All that caused this was the break of a Software Mirror which initially did not have an issue.   All was working fine several reboots after.   Then for whatever reason, an error crept into the Boot Configuration Database halting the system from starting.

So what to do?  If you could get the “Start Disk Repair” to scan the drive structure all would be fixed.   But normally the Windows Recovery Environment relies upon the fact that the Operating System can be seen BEFORE trigger “Start Repair”.  Since it couldn’t see the O/S, it wouldn’t trigger “Start Repair”


Well guess what? If that happens you’re ok.  If you do have the drivers loaded and are sitting at the prompt of


with that Cursor blinking away while you Curse at it, Just change to the


And just run STARTREP.EXE

And you’ll find the Start Repair is running and happily doing it’s work.  You should find it will now fix you and have you up and running as it should.  Also the other nice trick you have to work with is if you boot up and FORGET to add the hardware drivers in?  You at the Recovery Console type in


To load the drivers in live.  If you wish to re-run the normal SBS 2008 (or Server 2008) launch screen to triggers things naturally WITHOUT a reboot just execute


Then life is good.   Either way you’re up and running without a need to have the tech who did the repair kicked in the butt :)

The Energized Tech



The time has now come at last.  The OIympics are over and it is now the time for the REAL games to begin! the Scripting Games!

From April 26th 2010 to May 7th 2010 the Action will ERUPT and fire across the planet!

What is it about?

Do you fancy yourself a scripter?  Does the very thought of typing a GET-CHILDITEM for fun make you giddy?   Does Automation of the systems through the Power of Command level prompts drive your day?  Does YOUR Better half find you hiding in the back corner of the corner of kitchen writing out vbScript on the back of the garbage can?


Then the time is now for YOU to show your gusto.  To launch your abilities and test just how MIGHTY of a scripter YOU are!  The Chance to battle ONE on MANY (or just to test yourself) with Scripters across the planet Wielding Powershell and vbScript as their axes battling profusely to be the VICTOR!


There are total of Twenty Events in the 2010 Scripting Games.  10 Beginner and 10 Advanced.  Events are hosted on Poshcode, the repository where only the GREATEST of scripts lay.


There are also plenty of online resource available to YOU to be the BEST that YOU can be in The Games!

Want to follow in the action?  Keep your eyes on the Hashtag #2010SG for details and action as the data flies out and the action tears loose!

And you can Support the 2010 Scripting Games FREE of charge by going to and choosing one of TWO excellent Avatar pins for the games!

So engage now!  Watch , The Scripting Guys on Technet and your many Community Websites INCLUDING for further details! 

Keep your eyes on the web, your fingers locked on the keyboard and the GUI tucked away in the drawer.

For the 2010 Scripting Games and coming soon!



After reading Adam Preston’s Blog post about Making Powershell Talk I thought to myself “Finally!  We can make Powershell ACTUAlLY Sing!”

Well maybe not sing, But I quickly whipped it into a useful function in my Powershell Profile now called “OUT-VOICE” which can now upon command speak.

So armed with the original “Highway to Powershell” Lyrics, 5 minutes in Notepad and 1 one liner.

We have the REBIRTH of Highway to Powershell.

Save the Following Script as “HIGHWAY.PS1” and make sure a text file called Highway.csv (Second pile of text) is in the same folder

--------- HIGHWAY.PS1 ----------------

# Highway2Powershell.PS1

function global:out-voice ($words) { (new-object -com SAPI.SpVoice).speak($words) }


# End of Le Script

--------- HIGHWAY.PS1 ----------------


-------------- Save all from below down as HIGHWAY.CSV ---------
It's so easy
and it's free
Download it now it'll take no time
Get it in
use it now
For to not would be such a crime
Shell of Power
Pipes of Dreams
Kiss your last wasted minutes away
Party now
let's get down
I can't wait to start this day

I'm using Powershell
Cruisin' with Powershell

No Batch Files
Wasted minutes
So much power I've got to abuse
Using Get
Add it in
Clear data and Out it to you
Hey Bill G
Stevie B
Too much time on my hands
Done my work
Before I started
I won't ever use those other brands

I'm using Powershell
Microsoft Powershell

Don't End Task!

I'm using Powershell
Windows Powershell

No systems goin' down........
On my watch.

I'm usin' Powershell

------------------- HIGHWAY.CSV --------------------------


I got a little bit inspired today.   If you saw an amazing Sharepoint Guru found out how to make Powershell talk by using  NEW-OBJECT and linking to the Speech interface in Windows.

Then all day long in the back of my head I kept thinking, “Now if I could get Powershell to Play Music, I could get it to do Karaoke”.

Yes it was an odd day, which spawned THIS function.  INVOKE-MEDIA

Really it’s no different that any other link to Com Objects.   I create a link to it using a Variable in Powershell and attaching to the Media Player in Windows.  Of course, if you don’t have the Media Player or a sound Card (or a computer for that matter) this will fail miserably.

But all I did to figure it out was

1) Dig into the registry under HKLM\Software\Classes for what appeared to be the Location of Windows Media Player and Guessed (Turned out to be called “MediaPlayer.MediaPlayer” for the COM name (well THAT wasn’t very creative!)

2) Created a link to it using

$PLAYER=NEW-OBJECT –ComObject ‘MediaPlayer.MediaPlayer’

3) Piped the results into a GET-MEMBER to see what Methods and properties were available.   Turns out quiite a few to understate.

The ones that caught my interest were “FILENAME” (A Property) and “Play” a Method.

So now executing the following new lines


Produced the the “Chimes.Wav” file playing in the background

To write this into a useful function just execute

function global:INVOKE-MEDIA ($Filename) {

$PLAYER=NEW-OBJECT –ComObject ‘MediaPlayer.MediaPlayer’


And to use that function just simply execute

INVOKE-MEDIA ‘C:\Windows\Media\Chimes.wav’

Or what so ever drives your fancy as a file.

Powershell, It’s easier than it seems

The Energized Tech


Event Code: 146656


03/29/2010 06:30 PM - 10:00 PM


Sheridan College – Oakville, Ontario
room J102, Levy Centre

1430 Trafalgar Road
(Ceremonial Drive, park left lot)
Oakville, ON L6H 2L1

driving directions


General Event Information

Featured Products/Topics: Windows 7, Security

Dana Epp [MS Security MVP since 2006] will discuss the following topics:

• The value of Windows 7 Ultimate/Enterprise and full disk encryption using Bitlocker.
• The protection of Windows 7 Professional with alternative full disk encryption such as TrueCrypt, Sophos EndPoint Security, CheckPoint Full Disk Encryption etc. Contrasting why BitLocker is better.
• The value of AuthAnvil (Dana's own product developed by his company Scorpion Software) for providing identity assurance and offline strong authentication protection to the Windows 7 logon of notebooks.
• The value of DirectAccess in Windows 7 Ultimate/Enterprise
• The value of BitLocker To Go and AppLocker.
• The value of RD Gateway, RD Web Access and RD Remote App for remote access.

Dana will demonstrate most of the above. Dana is a very well known and excellent speaker. His presentations are always informative and entertaining. Come and get your questions answered!

 Dana's MVP BIO...



Today in the Feeds a Sharepoint 2010 Guru @_apreston posted a Tweet.

“Make Powershell Speak”

I went and quickly pasted in the code into Powershell and sure enough, it called up the Speech API and SPOKE! (which is actually a feature in Windows Accessibility)

Which shows the raw power of Powershell, the fact that if the feature is in Windows and there is some way programatically to access it, Powershell can use it.

So now of course, I thought this could be a cool function to add to Powershell as a regular feature.   And for those of you who are new, this is a way to see how EASY it is to add on features for yourself

So from Adam Preston’s Blog the command was simply

(new-object -com SAPI.SpVoice).speak(“Welcome to the SP2010 Blog”)

So if you would like to make this a regular function in Powershell just add this code into your profile or as a “Dot Sourced” script

function global:out-voice ($words) {

(new-object -com SAPI.SpVoice).speak($words)


There done! You see all we need to do? 

Enclose the original code between between {} (Parenth… Paren… Them funny brackety things)

Place the Take the information (text for example) you want to be passed through and replace that with a variable (In this case $words)

Place the word “Function” and a name to have the function called up by “out-voice” and in Round brackets (), the variables you are passing IN to the function (mattching the names of those you used in the code)

Placing GLOBAL: before the function name allows it to be called up “Globally”


So hopefully you can see how easy it is to create a function in Powershell and how much fun it is to play about thanks to Adam Preston we now have a simple yet elegant piece to add to our Powershell library.   The ability to speak

The Energized Tech.

A recent announcement from Microsoft for Windows 7 was the removal of the Hardward Acceleration as a requirement to running Windows XP Mode.  

First off, hats off to Microsoft for doing this.  I completely understand WHY they forced the requirement initially, absolute SPEED for Windows XP mode.   But the need to run Windows 7 on a greater level of platforms AND allow us to use Windows Virtual PC for creating Virtual environments was a greater need.

Because After all, Windows 7 runs on just about EVERYTHING I’ve thrown at it!

So go now to and you will see a THIRD option for downloading Windows XP Mode


This third update seen on the right is an update that allows you to run Windows XP Mode on lower end hardware.   The Caveat to keep in mind is you are EMULATING the hardware at this point which means a performance hit.  But if the machine in question happens to be a Pentium 4 3.0 chip (which wasn’t a slouch and is still in current office environments) You may not notice it as badly.  

I have personally installed it on a Centrino class laptop with 2.0Ghz Mobile processor.  Yes, there was a hit as the application loaded.  But I can now run Legacy Windows XP software SEAMLESSLY on my laptop.  More importantly I now have the NEWEST Virtual PC.  

So I can now under Windows 7 on a 4 to 5 year old laptop Demonstrate my Server 2008 environments and Powershell demos without incurring the cost of new hardware.  Which is good for my wallet and my piece of mind with my wife.

But on the same token for a Small Business, if you have an application that only runs under Windows XP?  You have the option of running it seamlessly in the short term until a) the vendor gives you the update or b) you find a better long term solution.  However you are NOT dead in the water, you do NOT need to buy new Hardware just to run Windows 7 (except maybe some extra ram, which is cheap nowadays) and you’re in business with the most Secure O/S out there right now

So if you haven’t tried Windows XP Mode yet and you have Windows 7?  Now you have no excuse.   If you have a legal copy of Windows 7, the license to run Windows XP in XP Mode is built right in.  

Give it a whirl.  It’s a free feature in Windows 7 and you have nothing to lose.

The Energized Tech


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


Ah excellent, you’ve all returned.   I see you have either decided to learn more or you have come seeking a refund.  

Well since this added to a deposit of $NULL

Oh? You understood that term?  Move to the top of the class.  Because today we’re going to show you two loops for the price of one.  THAT’S Right! TWO!

Well really, they are two that are so similiar, that if you know one?  The other is it’s opposite.  Like Laurel and Hardy, Abbott and Costello, ITPros and Developers!

The Do While and Do Until loops in Powershell (Like in other languages work on two premises.  Keep doing this WHILE a condition is true (IE: WHILE the Boss is angry, pretend to work) or UNTIL a Condition is Reached (UNTIL the Boss catches you Twittering and Blogging at your Desk, Keep going at it)

WHILE is easy it looks like this


So a good example of WHILE in action could be (and this a good example of “Validation”)



# THAT USERNAME.  Any Ideas?


Now in truth that is a HORRIBLE piece of code, unfit for any department but what it DOES is keep LOOPING WHILE the magic word “QUIT” is NOT typed in.  It’s just an example of how it COULD be used not how it SHOULD be used.  (Thus why am an ITPro and not a Developer)

A good example of the Do UNTIL loop would be


To see how it really works…

DO {

WRITE-HOST ‘Enter a Name now!’

} UNTIL ( $SOMENAME –eq ‘NotMe’ )

See?  Again not the best Example of how you SHOULD do it but hopefully an example basic enough to grasp on.

We’ll poke a bit more into other things next time. Maybe something fun like Quantum Mechanics.

Ah, the back row just fainted dead again…

Cheers all

The Energized Tech


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


Ah excellent, you’ve all returned.   I see you have either decided to learn more or you have come seeking a refund.  

Well since this added to a deposit of $NULL

Oh? You understood that term?  Move to the top of the class.  Because today we’re going to show you two loops for the price of one.  THAT’S Right! TWO!

Well really, they are two that are so similiar, that if you know one?  The other is it’s opposite.  Like Laurel and Hardy, Abbott and Costello, ITPros and Developers!

The Do While and Do Until loops in Powershell (Like in other languages work on two premises.  Keep doing this WHILE a condition is true (IE: WHILE the Boss is angry, pretend to work) or UNTIL a Condition is Reached (UNTIL the Boss catches you Twittering and Blogging at your Desk, Keep going at it)

WHILE is easy it looks like this


So a good example of WHILE in action could be (and this a good example of “Validation”)



# THAT USERNAME.  Any Ideas?


Now in truth that is a HORRIBLE piece of code, unfit for any department but what it DOES is keep LOOPING WHILE the magic word “QUIT” is NOT typed in.  It’s just an example of how it COULD be used not how it SHOULD be used.  (Thus why am an ITPro and not a Developer)

A good example of the Do UNTIL loop would be


To see how it really works…

DO {

WRITE-HOST ‘Enter a Name now!’

} UNTIL ( $SOMENAME –eq ‘NotMe’ )

See?  Again not the best Example of how you SHOULD do it but hopefully an example basic enough to grasp on.

We’ll poke a bit more into other things next time. Maybe something fun like Quantum Mechanics.

Ah, the back row just fainted dead again…

Cheers all

The Energized Tech


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


So by now, it seems that some of you have been removing your Peril Sensitive Sunglasses.   Which means either you’ve had too much Jolt Cola, you are TRULY daring ItProfessionals; or you’re starting to get comfortable with some of the terms floating about now.

So now if you HAVEN’T Gone loopy and had your pupils fall out of your head? I do believe you will at least go loopy.

At least I am.  We’re going to talk a little about loops. 

Loops we’ve already done in the past, anybody remember Batch Files in Dos.

“…… Duuuuuh what’s DOS?…”

Ah yes, I forgot.  Modern day ItProfessionals might not remember the hard core days of IRQ's, Address Lines and COPY CON: to create Batch files.   Batch Files were not for the weak of heart.  vbScript?  Pah!  Give me a FOR %%A and….

Right sorry where was I? Loops!

Loops allow you to repeat tasks automatically until a condition is reached (or if you’re really loopy, Repeat forever.) The latter is referred to as an endless loop.   Also known in the industry as the “endless upgrade cycle”.  ItProfessionals can understand THAT.

So our first loop we’ll look at is the FOREACH-OBJECT ( Very similiar to using a FOR NEXT in Basic or a FOR %%A IN in Batch files ).  Remembering that in Powershell we deal with nothing but Objects, FOREACH-OBJECT is actually very easy to work with once you understand a little of the Syntax.


Ok I see a FEW of you still shy away from THAT Development term.  By the of all this you’ll be cracking jokes in Machine Code, never fear.  FE AD BE AA 00! LOL! LOL!


Never mind, bad joke.  Too “Developery” I see at this time.

So let’s take a look at a typical FOREACH object loop in Powershell.


Where the $PIECE is your reference to WHATEVER line in the OBJECT the FOREACH-OBJECT loop is PRESENTLY LOOKING AT

That’s it.   It’s a very simple loop that goes through an Object and uses it one Entry at a time until it hits the last bits

So let’s see a simple Object we deal with on a regular basis, a Directory and how that would work in a loop.


…and yes this would give us TRULY a “Big Pile of Stuff” but to step through and say LOOK at this directory you would execute a loop like this




All this loop does is Demonstrate a few things.

It will step through the list one Item at a time and show you each object.  It will also show you that as you step through the list, you can access individual properties of those objects like the Name or the CreationTime. 

You can even execute other Commands (including piping).   Almost like a Powershell Script inside a Powershell Script.   I threw the “MORE” onto that one PIPE with GET-MEMBER so you could see a way to pull out properties of an Object like “$THING” within a loop.

And the loop simple runs until “EACH” of the “OBJECTS” are done and “FOR”gotten.

Ok that Joke was a complete stretch but hopefully you got the point.   There are many ways to use the FOREACH-OBJECT, like counting from 1 to something.  Because you can put the Objects in Statically as well.

So to count up (Oh just BECAUSE!)


It can even do the ALPHABET!

FOREACH ( $LETTER in 1..26 ) { [CHAR] ($LETTER+64) }

But really that’s ALL the FOREACH-OBJECT loop does!  It just steps through a list INSIDE an OBJECT until it hits the END of the LIST.   And all you’re using the first Variable for is your Reference to that list.

Remember as well when you’re working with Objects, you always have .Count property, so if you’re working with an Object List, there is Always a way to tell the size of the Object at that time.

Well, we’ll let stew on that for a while.  It looks like the back is getting fidgety and crimping LAN cables with their teeth again.

Until next time, May the Power be with YOU

The Energized Tech


*** 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 there may not truly be any Fun or Profit today here.  I thought it was a catchy title that would probably trigger every Spam filter across the planet.

Actually no, I lied, there is a little fun involved and some Discovery   You will profit too; in an increased level of knowledge. 

So I wasn’t COMPLETELY lying with the title.

So in Powershell we can access various COMObjects in the system.  I’m not going to try and cross into DEEP DEEP stuff about COMObjects.  To be quite honest I don’t 100% understand WHAT they are but I do understand this.

It is a way to DIRECTLY interface with many applications and Systems within Windows.  Let’s take an example.  A Word Document.

As Morpheus would say “In the Real World Neo we start up Word, Hit File Open, and work with the documents…”

Using COMObjects we can talk DIRECTLY to Microsoft Word.

To do this we use the NEW-OBJECT Commandlet and specify the name of the Object. Now to find the COMObject name can take a little digging but there is an Easy Cheat.  They’re all stored in the Registry! (Sshhhhhhh! Don’t tell!)

Many are sitting right there under HKEY_CLASSES_ROOT but I wouldn’t recommend going that route.  You’ll be sitting there all day long mining the Registry (which COULD be fun if there was gold in there) What you CAN do is search for keys called “.application”

These are not the ONLY ComObjects you can use, but it’s a start.  So searching under HKLM\Software\Classes and doing a find for “.application” only searching for “KEYS” (So clear off the boxes with Values and Data)

First one I encountered on my computer with Office 2007 was “Access.Application”

This suggests it PROBABLY has something to do with Microsoft Access (This is a guess, but if you dig into the values of this key you’ll see it has a default description of “Microsoft Office Access Application”

So if I want to programatically Access “Access” (or there was a play on words!) I execute this command


You might even find it launches because you DID after all just call up an Launch access in the process.

Here’s where the fun starts.  Take out the magic Period “.”, tack it onto the end of $MYACCESSPROGRAM in Powershell and start hitting Tab.  You’ll see some quasi familiar features there. 



You’ll see the screen fill with a plethora of goodies.  Those are all Properties and Methods attached to the Access application that you can access DIRECTLY from a Powershell script (Providing of course the destination computer has Access of course)

This is different for every program.  Some don’t have COM+ ability but many do.   It is all thoroughly documented online as MSDN.COM for each one.  But sometimes if you just play, you might be able to figure out the pieces since the naming structure DOES actually make sense.

I’ll leave this one in your hands.  It’s really interesting to see just what you can access from Powershell at this point.

Powershell, cleaning up your Office for you.

The Energized Tech


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




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.


Will give us the result of


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


to give us


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


And get a result of


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


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. :)

The Energized Tech


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


We have an OBJECT with some characters


Pulls up


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.


We get this


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?

The Energized Tech


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


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




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.



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




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 $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 ;)

The Energized Tech


If you’re reading this blog, you know what I am.  I’m a tech.  I a tech who deeply loves what Powershell does to help enable me on my job.  Not because Microsoft says so, but because I’ve gone from one side of the Coin doing pure GUI and a pile of Command line functions, to one Interface. 

So the thing I was playing with Today was split(). I was trying to figure out how to separate a FILENAME from a DIRECTORY name in a string that just had both.  My Example?

The $PROFILE variable, The Object that contains the pathname and filename of your personal Powershell Profile. Typically it looks like


So how do you pull just the filename out of that?  Well actually if you knew that the filename was always a certain size and ALWAYS at the end you could use a substring() and say something like “Give me the last 20 letters”.  But a better way would to be find out how to pull out “all the information after the end of the Directory Name”

Which is where split() comes in.  If you run


Which says “Everytime you see a "/” in that line, break that into another chunk and store the results in the $PIECES object.  This of course is a name I completely made up, you could call it $PICTURESOFLILLY if you so liked ;)

What $PIECES will look like will be


Now here is where it starts to get easy.   The last Line will ALWAYS be the filename.  The preceding bits will always be the directory since the SPLIT() breaks it down in the ORDER it SEES it.  If you run a GET-MEMBER against $PIECES you’ll also notice there is a Property called Count.  Count is ALWAYS the number of members in that array.  Always.


Which is 6. So since I now have a simple list, and a way to know how many pieces are in that list, I can VERY easily say “Show me the last piece in the list which I already know is the Filename”


We say –1 in the Count because although you an *I* count from from 1 to 6, the computer starts at 0 for it’s numbering of the array.  So there ARE 6 pieces by the count but they are numbered from 0 to 5

So if you had to make all of this into a nice little Function here is how easy it is!

function global:GET-FILENAME ($FullPathName) {

return $FILENAME


If you like to return the Directory as well?  Just use the trim() Method we discovered yesterday and “Trim” the filename from the string! You can add that in one line and return both pieces like this.

function global:GET-SPLITFILENAME ($FullPathName) {




Now wasn’t that easy?

Powershell.  The Shell of Champions

The Energized Tech


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


In Honor of St. Patrick’s Day, I am going to introduce you to two more methods, easy ones to use and learn.  And they’re cousins.

St. PaddyLeft() and St. PaddyRight() and they a…..


Ok if the back section would clam up, it wasn’t THAT funny.  And honestly, who put Guiness on the cart today?

They are actually padleft() and padright().  Their tasks are simple and obvious sounding.  to “Pad” data, whether blanks or other data.

We won’t go into heavy detail on each one as they Do function identically, the only difference is whether data gets put to the left or the right.

So we have a sample Object.


Again, Piping $BEER through GET-MEMBER will show us a list of Properties and Methods, here are the two we are concerned with.


And again rerunning that same set of Methods with a Format-List which show us their definitions more clearly


Now these ones don’t look so bad.  Even the bunch at the back seem relaxed.  And that’s because they have two Definitions to work with, much like the “substring()” Method.

In both cases they are saying “Give me a Number to describe the Width I am padding” and the second Definition simply says “Yeah same as the first guy but tell me what CHARacter to be PADDING it with”

So $BEER.padleft(20)



Because what it is doing is Padding the Character string out so it is at least 20 spaces, and the “Padding” goes to the Left.

And doing a


Gives us a


Since we are “Padding” it up to be at LEAST 12 characters. And we are padding it was an “!” for the filler.

Now this is all fine and dandy.  All this Padding on St. Paddy’s day.   But these so serve an important function that ALSO get’s introduced today.

Much like getting a nice haircut before heading out, You usually combine Padleft() and Padright() with Trim().

Trim has a definition so simple it’s not worth mentioning.  But because I like putting pretty pictures on the screen I’ll post it anyhow.


See two simple definitions, because it IS a simple method.   It “TRIMS” off the excess.

So with our previous example of $BEER.padright(12,”!”)


Running a trim() on top of that does two things.  If there are any blank spaces it will “Trim” them off (In Either Direction I might add). The other option in Trim is to specify what characters to Trim out of the left or the right of the object.

So if you had


in $BEER the result from running a

$BEER.Trim(“!”) would be


And similiarly  if you had Spaces before or after like this in $BEER


Running a $BEER.trim() would strip off all spaces at the beginning and end to give you


And you can even attach Methods together like this


Would also give us


Because it would execute the Padright(12,”!”) and then IMMEDIATELY after run a Trim(“!”) on the results.

A little confusing but not so much :)

That’s it folks.  There’s nothing more to it.   See?  Even the guys in the back didn’t fall asleep this time!  Methods aren’t so Nasty once you get used to them!


..and With all this talk of Guiness, I think I’ll have me one.  Happy St. Patrick’s Day

The Energized Tech


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


“When we left our heroes last time…”

Ok let’s remember, this article is to try and get ITPros (non coders) to grasp some of the Methods and techniques that Developers take for granted.   Working with Objects.  Today we’re going to take a quick look at another Method called “split()”

Unfortunately due to a lack of sponsorshop (The other 25 letters and 10 numbers are in the Sunny parts of Floriday relaxing) we have a more “constrained” budget.  So we can’t afford any punctuation marks.

So with that in mind, I’ll introduce you to split()

Split() allows you to to (as it sounds) “Split” strings into chunks an array of objects based upon a common piece.   An example of something we “Split” all the time without thinking about it as a CSV file.   We see a single line of Commas separating the info, we bring it into Excel and we “split” those lines into columns.   So split is something we do all the time.   Only know we’re going to be able to use it on ANYTHING!

“Can we use Split() on this $50? I need change for the parking meter!”

Tap tap tap tap tap…. There’s always a smarty pants in the back.

No but you can use it for is to break information up to manage it if there is a repeatable pattern.   And like other Methods() we find out how to use it with Powershell.

So let’s create a small phrase for fun and store that “Object”

$SillyPhrase=’The Quick Brown Fox Jumped Over the Slow Lazy Dog and Broke His Leg and is now suing the Dog for Interference’


Now again like before all we have to do is right this through a GET-MEMBER to see what Methods and Properties are available on this object like so.

$SillyPhrase | GET-MEMBER

Which will give us a long list of goodies (you can try it in Powershell to see, the One we’re interested in is Split()


As before, run that through a “FORMAT-LIST” to read the Definition.

$SillyPhrase | GET-MEMBER –name Split | FORMAT-LIST

To get this definition


****KLUNK!!!**** ***BAM!!!*** ***CRASH!!!*** ***THUD!!!***

Excuse me for a minute?  I need to get some smelling salts for the back row…

Ok, THAT Definition does appear to be like taking apart a car engine, there SEEMS to be a lot to it.  But not if we break it down.  I ‘ll separate the definitions into rows and hopefully that helps you to a) see what it REALLY means and b) see how to separate the different methods of calling up a particular Method.

Yes, some of them have more than one, Some have none.   This one has errr…. Just a few extra.

So this definition which starts out as

string[] Split(Params char[] separator), string[] Split(char[] sep
arator, int count), string[] Split(char[] separator, System.String
SplitOptions options), string[] Split(char[] separator, int count,
System.StringSplitOptions options), string[] Split(string[] separ
ator, System.StringSplitOptions options), string[] Split(string[]
separator, int count, System.StringSplitOptions options)

Now before the back row falls over in a faint, let’s break that down

string[] Split(Params char[] separator)
string[] Split(char[] separator, int count)
string[] Split(char[] separator, System.StringSplitOptions options)
string[] Split(char[] separator, int count, System.StringSplitOptions options)
string[] Split(string[] separator, System.StringSplitOptions options)
string[] Split(string[] separator, int count, System.StringSplitOptions options)

Now it really isn’t that bad to deal with.  If you can see, in the definition, each line is just a definition separated by a Comma and preceded by the beginning half of the definition (Type of data being sent in and the Method name)

So wonderful, great.  We have 6, Count ‘em SIX defintions to the Split() method and we haven’t done anything useful with it.  Well I did say it was easy to use didn’t I?

$SillyPhrase.split(“ “)

That’s an example of our first definition.  It’s PARAMeterS are a CHARacter being defined as the SEPARATOR to Split the Object.  We are telling it what our “Delimieter” is between the Characters.  The output of our “Silly Phrase” will be this.


A bit of a mouthful, but you can see what the “Split()” method does.  It can Split things (Well I guess the name was a little obvious) and the parameters we pass to it govern how the split is done; and in some cases; where.

$SillyPhrase.split(“ “,5)

Which is what the second definition refers states, “Tell where to split on (what Character) and how MANY splits to make (5)” which will give us this result

Jumped Over the Slow Lazy Dog and Broke His Leg and is now suing the Dog for Interference

There are other options you can play with on the split that dive right into Developer land, but for the basic use, all the ITPro has to know is “What am I splitting with and do I need to stop"

That’s it, nothing more.  And the crew in the back row can now wake up.   Your snoring just knocked out a ceiling tile. :)

The Energized Tech


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

Today my fellow ITPros, we are going to step OUT of our element and do something SO scary, you must just throw your Fluke meters away in Disgust.  

Yes, we’re going to use a METHOD!

Over the next while, we’re going to learn a LOT of “Methods”, and ye Lords of COBOL willing; you will ENJOY it.

Funny words aside, we’re going to little by little show you some of the Methods available in Powershell and perhaps get you a little bit used to digging into the land that Developers live in.

Today’s Method is brought to you by the letter “S”.  It is “substring()”

Substring() is a function if you would that lets you pull out pieces of a Cha……

“Zzzzzzzzz Gzaaawwwww..Snort snort..”

“You in the back, WAKE UP!” *WHAP*


I can always spot a snoozing ItPro when I’m talking out of their scope. So let’s keep this simple.

You have a String, Text information.  You need a PIECE of it.   Substring() is one of the Methods available to you to do just that.   Nice and simple as well.

If assign a small word say…


To a variable and run that through a GET-MEMBER I get


These all all the Members of object $Word.  As you can see we have a Method call Substring().   To access a Method is almost just like accessing a Property.  Simply typing a “.” between the Object “$Word” and the name of the Method you want to apply to the Object “SubString()”

So we just type in…




And yaaayyy it just….


It just immediately gave us a big Wawa error

That’s because many methods require additional parameters, information to know what you WANT them to do.  Some don’t.

To get an Indication what your Method “Substring()” wants you can have Powershell TELL you.  The very same GET-MEMBER we ran before can be used to just tell us about “Substring()” (or any other Method for that matter)

Just add on –Name and the name of Method after a ‘GET-MEMBER’, then pipe it through FORMAT-LIST to see all the details.  Look for “Definition”


What this definition translates to is it wants the parameter in one of two ways.

The first one

string Substring(int startIndex)

Says “I want you to put an INTeger in here (a number) saying WHERE to start”

So if we do


(remembering our Word was ’SuperCaliFragilIsticExpiAliDocious’) we will get the Variable $Word starting at position 10 of the character array and all the rest)


Will be what we see

and if you do a


Your results will be


Since it starts in by 25 characters. And now it gets fun.  The OTHER definition of substring() was

string Substring(int startIndex, int length)

This translates to Says “I want you to put an INTeger in here (a number) saying WHERE to start, then I want another INTeger (num……


“…Ggggggznnnzznznnn……Zzzzzzzzz Snrt..”

Excuse me for a minute.



…Ahem, nobody sleeps in my Blog.

So as I was saying This translates to Says “I want you to put an INTeger in here (a number) saying WHERE to start, then I want another INTeger (number again) saying how MUCH to show from that point forward.

So with the name $Word we can now do this


will show us


Since that part of the string is 5(Five) letters in and we’re showing 4(Four) from that position forward.  Or I can do a


Which will show us


Because again, it’s going in 24(Twenty-Four) characters, and displaying the next 6(Six)

The thing is, once you understand a LITTLE about one Method, it’s not TOO horribly difficult to pick up on some of the rest.

You may now return to your regularly scheduled channel and Remove the Peril Sensitive Sunglasses.  And Sleepy from the back can go back to work. :)

The Energized Tech


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

That’s it.

Here’s an example of simple Object, a Directory.  When you type in

GET-ITEM C:\Powershell

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. 

$JustAnObject=GET-ITEM C:\Powershell

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


After July 13th 2010, Windows XP SP2 and Vista RTM will no longer be supported by Microsoft.  This means making sure your systems are at LEAST running Windows XP SP3 or Vista SP1.

But for you the ITPro, you need to quickly and EASILY know which machines need the update.

And for this, Powershell is your friend and greatest ally.

All you have to execute is a simple WMI Commandlet


GET-WMIOBJECT win32_operatingsystem


This ONE little Commandlet will tell us almost ANYTHING we need to know about that version of Windows on a computer.  SKU, LicenseKey and more importantly Name and Service Pack of the software.   Again piping this through a GET-MEMBER will tell us what properties are there.  There are Three we are interested in


So if you select those objects like so

GET-WMIOBJECT win32_operatingsystem | SELECT-OBJECT Name,ServicePackMajorVersion,ServicePackMinorVersion

You’ll have the details for your local computer.   Now if you execute that with the parameter computername and the name of a remote Workstation (presuming WMI is enabled)

GET-WMIOBJECT win32_operatingsystem –computername SOMECOMPUTEROVERTHERE | SELECT-OBJECT Name,ServicePackMajorVersion,ServicePackMinorVersion

You can pull up the details remotely for any computer.   And now if you have a LIST of computers ready (Let’s try a list from Active Directory, pulled from Quest)

GET-QADCOMPUTER | foreach ( GET-WMIOBJECT win32_operatingsystem –computername $_.Name | SELECT-OBJECT Name,ServicePackMajorVersion,ServicePackMinorVersion )

Now all your work is done.  You can easily determine which machines need the Service Pack or in some cases, need to be upgraded to a newer O/S!


All thanks to a free utility called Powershell, and my closest friend :)

The Energized Tech

Toronto Sharepoint Camp

| | TrackBacks (0)

This Saturday in Downtown Toronto is a free event called Toronto Sharepoint Camp.

It’s Free and for the Developer Community, but honestly if you’re the least bit curious about Sharepoint on some level (especially with Sharepoint 2010 being released soon) I would check it out.

All details about the event are here and for Registration.

It’s located at

Manulife Financial Corporation
200 Bloor Street East
Toronto, Ontario
M4W 1E5

Click Here for Map

On Saturday March 20th 2010

Seek the innerpoint Sharepoint guru in you and gather to learn.

Oh and by the way… It’s absolutely FREE (Other than bringing $5 to buy a lunch)


The Energized Tech


Last time we saw that you can pull out Processes using GET-WMIOBJECT as well as GET-PROCESS

This time we’re going to show you WHY you should use GET-WMIOBJECT.  

Again the strength of GET-PROCESS is it’s simplicity.  That’s also it’s weakness.    GET-WMIOBJECT is a little more complex to work with but like all great tools, it has it’s place.  Here is one.

We can isolate WHO owns a process using GET-WMIOBJECT.  It takes a small Script to do it but it works well.  Each Process you access with GET-WMIOBJECT win32_process has a Method called GETOWNER()

To find the owner of a process we Get the process, and run a GETOWNER() on the process.

So with our Present Function we can modify it to list those Process Names, IDs and now the OWNER.

Function GLOBAL:GET-PROCESSUSER ( $ProcessName, $Computername ) {

(GET-WMIOBJECT win32_process –computername $Computername –filter “Name=$ProcessName”).GetOwner()


So now with this little function we have a VERY easy way to identify who is running a particular process on any computer in our network. 

And knowing who and what makes the next step, Killing that process; incredibly easy.

The Energized Tech


One of the beautiful things about Powershell is how it so EASILY leverages WMI.   It extends your administrative abilities so easily.

In the forums somebody was asking some very specific questions about terminating processes and it dawned on me that the GET-PROCESS Commandlet, although easy to use and Powerful, didn’t actually list WHO owned the Process.

Why do you care about that?  On a single workstation you might not.   But in a Terminal environment where you need to selectively terminate applications based either upon the APP itself or if a SPECIFIC USER is using an App.  Then you get a bit more granular.    But all of this is available via WMI.

And do you know who told me this?  The HELP GET-PROCESS –Detailed option

In trying to determine how to pull up the owner, the very documentation within GET-PROCESS says to use

$p=GET-WMI-OBJECT win32_process –filter “Name=’powershell.exe’”

as an Example.

So in playing with this Commandlet I found (By running a GET-MEMBER on the results) it has a “Terminate()” method as well.   And being that WMI-OBJECT also has a –computername parameter two pieces came together.

One, I can access the list of running processes with a UNIQUE process ID for each one as well as WHO is running them.  Meaning I can be VERY specific *OR* Very broad as I choose in terminating a Task.

So in running the following line

GET-WMIOBJECT win32_process –computername WRKSTATION01

I can access all tasks running on that workstation

GET-WMIOBJECT win32_process –computername –filter “Name=’IEXPLORE’”

And we can write this in a function easily too.


Function GLOBAL:GET-PROCESSUSER ( $ProcessName, $Computername ) {

GET-WMIOBJECT win32_process –computername $Computername –filter “Name=$ProcessName”



But so far we really haven’t done anything amazing.  This seems SO far to just be another badly done version of “GET-PROCESS” with more typing.

And for the MOMENT, you’re correct.  Which is where next time we’re going to see how to add in a User Filter to that list.

Powershell, fire up the Scripter in you

The Energized Tech


So you want to modify some attributes in the Exchange 2007 Send connector but you hate using ADSIEdit?

In all fairness, 90% of what we need to change is inside Powershell already for Exchange 2007.  But there are new Commandlets in Exchange 2010 that improve how you can limit to inbound / outbound mailflow.   

Many of those are a available in Exchange 2007 with Service Pack 2, but there is no Easy Safe way to change them.  One of these settings I blogged about last night which is “MaxMessagesPerConnection”.  Changing this normally involves using ADSIEdit, which is doable, but ADSIEdit is a VERY powerful tool and as such, a bit dangerous if you hit “Delete” in the wrong spot.

So I decided to port this to a Function, and make this easier to work with.

You can access ANYTHING in Active Directory so long as you know it’s “DistinguishedName”.  Every object in Active Directory has one, you’ll recognize it by the sequence.


Remember that.  EVERY SINGLE OBJECT in Active Directory has it.  And knowing that makes all of this easier.  

So first off, this attributte is component of your SEND Connector in Exchange.  Using GET-SENDCONNECTOR you can pull up your list

If the SendConnector was named “Mail to Internet Relay” or “Windows SBS Outbound Mail” better yet you key in

GET-SENDCONNECTOR ‘Windows SBS Outbound Mail’

and that you give you your Send-Connector properties.  But all we want is the Distinguished Name.  We can get that using a SELECT-OBJECT and store the results away in a Variable.

$CONNECTOR=GET-SENDCONNECTOR ‘Windows SBS Outbound Mail’ | Select-OBJECT DistinguishedName

Now we have the “Distinguished Name” for your SMTP Send Connector (or the one name “Windows SBS Outbound Mail”)

So we now pull out the String part of that object called “DistinguishedName” and store it away for the LDAP query.


To Query and work with Anything in Active Directory that does not have a prebuilt Commandlet like Quest ActiveRoles or Active Directory Modules, we use the [ADSI] Accelerator.  All we do is Plug the Distinguished Name in to look at THAT object and work with it.


We can now open the hood and access ALL of the attributes of the SMTPConnector.  Just pipe the $SMTPCONNECTOR through GET-MEMBER like this


If you are running Exchange 2007 SP2, there is a new Attribute called “msExchSmtpMaxMessagesPerConnection”.  To access the value of that (or any other new attribute) but tack it onto the $SENDCONNECTOR variable to see it’s value


Simply by assigning this with a value of say 1 or 2, (Adjust to suit your needs) will LIMIT outbound to one or two per SMTP session (unlike default which is send a lot and hope the SmartHost will accept it)


Then once done, you update Active Directory with the new Connector settings.


So what would all of that look like as a script?  Glad you asked, only about 3 lines really.  Take a look.

---------- Set

GET-SENDCONNECTOR ‘Windows SBS Outbound Mail’

But even nicer?  I can make this whole thing a function and add it to my Powershell Profile for daily use as a new Commandlet!

function global:SET-SENDCONNECTORMAXMESSAGE ( $NameOfConnector ) {

# Limit is the number of outbound messages to allow PER connection to SMTP Smarthost.
# 1 is very controlled.  The higher the number, the more messages you are able to send
# in a single shot, the greater the likelyhood you are treated a spammer.


So if you are running SBS 2008 (Small Business Server 2008) and have to deal with a SmartHost and their mail restrictions, update to Service Pack 2 of Exchange 2007 and work with this attribute.  It is the Holy Grail that you seek.

And make sure you thank Rick Lund-Pedersen of Around the Clock I.T. Solutions for sending me down the path to write this script. :)

The Energized Tech


Had a call today from a user that had to pull up a file.  The file wasn’t LOST but it was a IMPORTANT and of course they had no clue what the file was called.  Just that it was a Word document.

Well normally, as an Administrator or an ITPro you’d put your hands in the air and go “BLAH!” because pulling out an obscure file WITHIN a file system only know what day of the week it may have been opened with an obscure Window of information to search with was a TRUE impossibility. 

Two options, tell the user to go fly a kite or find some custom software.


I lied.  There’s a third VERY viable option.  Powershell.

Here’s a PERFECT example of how you can use Powershell to mine through the file system without heavy effort.

Ok first off let’s pretend we have the following information to work with.

  • The File is a Word document.
  • It was created about a Month Ago
  • It was created on a Thursday or a Friday (User is not sure)
  • And they’re PRETTY certain it was created between 10:00pm and 2:00pm

And you wonder why ITPros bang their head on a desk.  Normally THIS is a “Nope.  Not doin’ it, go find a dev, go explain to your boss, not my problem, fergettaboutit!”

But in Powershell this is all a NON issue

First off let also pretend I at least know what folder structure it’s in.  There’s only a million files inside \\CONTOSO\BIGfileShare so this shouldn’t take long.


Filtering by file type?  That part is easy.  That’s an option in GET-CHILDITEM

GET-CHILDITEM –recurse –include *.DOC \\CONTOSO\BIGfileShare


Now to make things easier, we don’t want to keep querying against the file system over and over and over.  So let’s store those objects away

$FILELIST=GET-CHILDITEM –recurse –include *.DOC \\CONTOSO\BIGfileShare

Now we can examine the data more quickly.  So let’s isolate that list of files Modified between 30 to 45 days ago.  We can do that easily by comparing the date files


$FILELIST | where { ($_.LastWriteTime –gt $Today.AddDays(-45)) –and ($_.LastWriteTime –lt $Today.AddDays(-30)) }


And now to show only files modified between 10:00am and 2:00pm over that time Frame.  We can access the HOUR or MINUTES in any [DATETIME] field by accessing that specific property and comparing with it numerically.

$FILELIST | where { ($_.LastWriteTime –gt $Today.AddDays(-45)) –and ($_.LastWriteTime –lt $Today.AddDays(-30)) –and ($_.LastWriteTime.Hour –gt 10) –and ($_.LastWriteTime.Hour –lt 14) }


But still ---- “I did this on a Thursday or Friday” that most maddening piece.

Everywhere else?  Headache.  Powershell?  PIECE OF CAKE


We can actually pull out the DAY of the WEEK in ANY date in Powershell.  And yes even in a File creation date or time.  It actually shows up as the REAL name of the day!

$FILELIST | where { ($_.LastWriteTime –gt $Today.AddDays(-45)) –and ($_.LastWriteTime –lt $Today.AddDays(-30)) –and ($_.LastWriteTime.Hour –gt 10) –and ($_.LastWriteTime.Hour –lt 14) –and ( ($_.LastWriteTime.DayofWeek –eq ‘Thursday’) –or ($_.LastWriteTime.DayofWeek –eq ‘Friday’)) }


All in all when you look at that line you may just say “WHAAAATTT??!!” and walk away.  But let’s break it down

$FILELIST | where {

($_.LastWriteTime –gt $Today.AddDays(-45)) 
($_.LastWriteTime –lt $Today.AddDays(-30)) 
($_.LastWriteTime.Hour –gt 10) 
($_.LastWriteTime.Hour –lt 14) 
( ($_.LastWriteTime.DayofWeek –eq ‘Thursday’) –or ($_.LastWriteTime.DayofWeek –eq ‘Friday’))



When you take a look all we are doing is examining ONE field, the “LastWriteTime”.   There are multiple properties in that field we can examine and we can get VERY granular.    Even down to Minutes and the very MONTH something occurred on.


Who would have EVER thought you’d have that much Power to mine the file system!  And in checking?  You can just as EASILY Distributed File Systems with this command as well.

Powershell.  It’s not just for Breakfast anymore

The Energized Tech

A good friend of mine and the Owner of Around the Clock I.T. Solutions Inc., Rick Lund-Pedersen had a bit of a stumbler.   A throttling feature that existed in Exchange 2003 and DOES exist in Exchange 2010 (which a Powershell Commandlet to Boot!) was MISSING from Exchange 2007.

We called it “maxmessagesperconnection” .

It allows us ITPros to limit the amount of messages sent out in EACH connection to a destination SMTP server.   In the case of those who use a SmartHost you’ll find some of them actually limit the number of messages you can tranmit in a single connection to reject possible spam flow.

Which is where this feature (which used to sit on the Virtual SMTP Server settings in Exchange 2003) was so badly needed in SBS 2008 and other sites using a Single Exchange 2007 server setup.  Such environments have a 100% locked off firewall and send all outbound mail to a Smarthost and use a FAST but inexpensive High Speed internet.  This completely negates the need for expensive onsite hosting while still leveraging all the power that Exchange 2007 has to offer.

But alas.  Microsoft (or Somebody on the Exchange Team to be more correct) in the ten Billion lines of code, misplaced a feature. 

MaxMessagesPerConnection.  But now that error has been corrected.  Download and update your Exchange 2007 Server to Service Pack 2 and some new objects will be in the Schema This service pack is ALSO approved for SBS 2008.  When you go to run it, it will have you download a VERY specific update for SBS 2008 (it’s small) that will launch and integrate Service Pack 2 for Exchange 2007 PROPERLY for Small Business Server 2008.  Once done, some new schema changes and features are added to Exchange 2007.

Amongst them, MaxMessagesPerConnection.  Now it’s not in the GUI or Powershell until Exchange 2010 but it IS there to edit.  Which is all we want.  Fire up ADSI Editor (Free download or if you’re using Server 2008 it’s already a part of your Management tools)

**** At this point, if you are NOT comfortable with editing Active Directory, stop.  This truly gets ‘Under the Hood’ and an “accidental Delete” will mean a restore from Backup. ***  TAKE WARNING AND TAKE HEED AND DO NOT EDIT THIS LIGHTLY ****

Once in ADSI Edit you’ll need to change “Select a well known naming Convention” to Configuration once the console loads up.


Once in you’ll have to start digging through the tree starting from

Configuration (Expand and then choose)
CN=Configuration,DC=Domain,DC=local (Normally this is your domain which will have a different name under Domain and Local, Expand and then choose)
CN=Services (Expand and then choose)
CN=Microsoft Exchange (Expand and then choose)
CN=First Organization (Expand and then choose)
CN=Administrative Groups (Expand and then choose)
CN=Routing Groups (Expand and then choose)
CN=Exchange Routing Group (GibberishNumber) (This will be different for each site.  Then expand and then choose)

In the Windows to the right you will see an Entry for each Send Connector you have.   Compare the names to the one you need to edit and double click that ONE.

Drill down until you find an entry called


Double click on it. It normally has no value and runs at Default settings (I don’t know the actual number, but it’s pretty unrestrictive)

Place a value from 1 or higher.  The Lower the number the fewer emails that are sent in a SINGLE SMTP CONNECTION to the Smarthost.  Click ok and close all of the Windows off.  Restart the Transport Service to ensure the new settings are picked up as well.

So if you have an ISP that restricts you to no more than say 30 emails in EACH SMTP connection (Exchange will send as many as you have be default) you’ll find either bad mail flow OR (most likely) you get dropped and have to explain yourself.  Embarassing and non productive.

With this change in, you have a way to keep outbound Mail flowing from Exchnage 2007 in a manner than keeps both YOU and the owner of the SmartHost happy.

And yes, I’m trying to write this into a Powershell script :)

And again, Exchange 2007 ONLY GETS THIS IN THE SCHEMA with SERVICE PACK 2 of Exchange Server 2007.

And again, a Special Thanks to Rick Lund-Pedersen of Around the Clock I.T. Solutions Inc for research into this issue and for finding the lost child.

Just keeping the mailflow on the go

The Energized Tech

I’ve never been a Fan of the Blackberry.  Just not a fan.

For what’s it meant to do, it’s good but I don’t like being locked down, I don’t like the lack of compatibility in it’s Browser.

It’s just not “ME”.

But I DO have to give some Kudos to the new Curve.  It’s what the entry level unit finally needed.  A good cleanup.

The present Curve sports the same newer “Look” as the Blackberry Bold.  Whether you like that or not is up to you, but it IS a fresher look.   They were also smart to NOT change the size of the Curve.  This means if you own one and upgrade, you don’t have to go scrambling for a new case.

It seems to be sporting a faster CPU and definitely responds nicer.  My particular model has Wifi which allows to cut down on the Data plan costs.   And finally, Finally, FINALLY somebody got a *CLUE* at Research in Motion to get RID of that STUPID mouse ball. 

How many users had to put up with THAT stupid idea based upon technology that was scrapped by the rest of the Industry ages ago?  How many people spent $50 to replace a 1/2 centimeter object that was ruined over and over by nothing other than a piece of FLUFF?!

Well the new Curve at least changed that, or more correctly; CAUGHT UP with the industry.   The Laser tracking is a much better mouse on the Curve.   The display appears brighter and moderately larger as well.   They also kept some legacy as well.  Same Battery and your memory card ALSO transfer over.

This is liked.

What they took away was the little light for the Video camera, which really didn’t matter.  The only time I used that was to stumble about my room in the morning as a “mini flashlight” (Call that an Undocumented Feature)

I’m still not a fan of the Blackberry as a whole, but this new model at least makes me feel less unhappy about using it.

the Energized Tech


A little “Black Sabbath” with Ronnie James Dio was coursing through my ears this morning and I just COULDN’T get this phrase out of my head.

“Code Powershell.”

So enjoy this and sing to yourselves quietly if you can find a copy of “Heaven and Hell” from “Black Sabbath”.  Sing this loudly and proudly.  I simply call this.


Send Him a task
That has lingered
Releasing his Code
He's a Killer of Evil

His CommandLets flow out
To his bidding
Automations bow down
To the Scripter

For his code goes on and on
With Powershell


He's Launching Remote
His One Liners
The Objects Pipe Through
And get filtered

He'll close up the loops
And repeat them
Do block until
all The Process is TRUE

For his code goes on and on
For his code goes on and on
It goes on and on and on
With Powershell


Oh yeah the systems repeat
All that's needed
Cuz The Shell it is out
And the Power is Here

The Functions will call
All the methods
With Dot Net empowered
All the processes flow free

For his code goes on and on and on and on...

In the Darkness
You'll never feel a fright
Power up Servers
In the middle of the night

Invoke-Method and
In Windows Vista
it's just a Role

With Powershell

Repeating your work
Is such a breeze
those many A/D's

Flowin’ through data
with nary a thought
Perfection is here
the system you sought

With Powershell

Foo Foo

Don't forget to use GET-MEMBER

Foo Foo

Using GET-HELP you find the Answer

Foo Foo Foo


Powershell is truly a wondrous giant box of toys. 

Just when you think you’ve figured it out, somebody puts something in front of you. Like the other day when Shay Levy unlocked the secret to Clearing the Windows Event logs.  I had to ask how he did it.

The process is both complex and simple but it DOES show you how you can play with Powershell and unlock the hidden treasures within.

In the case of the GET-WINEVENT Cmdlet (where there was no corresponding CLEAR-WINEVENT) Shay used a GET-MEMBER on the GET-WINEVENT Commandlet.

I didn’t understand at first why until I tried it myself.

Beside EVERY property, Method, Note Property is a reference to the Windows .NET Framework library being used.


At this point every IT PRO in the net reading this Blog post just fell asleep!


For those of you still awake, think of the Library as the world’s BIGGEST Database of information and systems within Windows.  They all have “funky little names”.

Let’s do one on GET-CHILDITEM to show you. On the right hand side of CreationTime you’ll see a reference to System.DateTime


You can go to to pull up specs on what this Library has and how it can be used.   Just type in the name within the top search box.  You’ll probably see a list pull down below you.  Click on the one that matches what you’re searching for.


The next Windows will pull up a HUGE pile of results from the MSDN online Documentation.  You’ll want to filter that out by .NET Framework 3.5 or 3.0 (Depending on whether you’re working with Powershell 1.0 or 2.0, not being a Developer I would suspect there are SOME differences between 3.0 and 3.5, so for best results, choose the version matching your Powershell)



In the resulting list  odds are the one at the top is your “Holy Grail” of information about that Library, or at least a tablet into it’s knowledge



The article should give you some indication about what you can do with it.  To me an ITPro? It’s mostly gibberish!  But’s COMPUTER Gibberish, so it’s sort of makes sense!

But here’s a neat trick Shay showed me to find out what you might be able to play with.   Take the Libary name and type it like this in Powershell




Yes A square bracket at the Beginning, one at the end and TWO Colons.

Don’t hit Enter, Hit tab, you may see some additional functions appear, sometimes properties.  I chose “DateTime” because it Does give us a few easy ones to play with

It produces with the Tab



Amongst others.   Hitting enter will either yield results or yield an error.  If it’s a feature in Windows that presently does not have a Powershell Commandlet, this is your doorway into unlocking those features.


It’s pretty heavy for ItPros I admit.  This is not our world.  But understanding a LITTLE of that world, unlocks a LOT within Windows and helps within the greater Master of Powershell


The Power is in YOU. 

The Energized Tech

Sponsored by ITPro Toronto

Register at while space is available!

Please note you have to PRE-register for this event in order to gain access as this is held inside IBM’s office.

Lotus Foundation Server UG presentation
Mar 16, 2010

Add to my calendar


IBM Canada
8200 Warden Avenue
Markham, Ontario L6G 1C7


Small business is still big business. Every company needs the ability to do e-mail, create, share and centrally manage documents and files and ensure that all their information is backed up and protected. But no one wants the hassle or expense of dealing with complex IT systems. Lotus Foundations is a family of software appliances that provide the essential software businesses need to focus on running the business, not managing computer systems.

Register at

Agenda and Presenters:

6:45 PM - 7:15 PM - Food and Drinks

7:15 PM - 7:20 PM - Introductions (why we are here, why you are here)

7:20 PM - 8:40 PM - Product Demonstration

- Architectural Overview (and why it's different)

- Getting running in no-time flat

- Integrated Base Capabilities and Functionality

- Backup, Network Router, Firewall, FTP, Web Server, File Server, DHCP, etc...

- Integrated Enhanced

- Antivirus, Antispam

- Add-ons and the role of Autonomics and Integration

- Start

- Reach

- 3rd Party

8:40 PM - 9:00 PM - Q & A


Hiep Vuong

Hiep Vuong leads up the HW Platform Strategy and Development and Technical Business Development for the IBM Lotus Foundations Team. Hiep has extensive background in appliances for the Small Business space having lead up development and operations at both SonicWALL and Net Integration Technologies (acquired by IBM in 2008).


Julie Reed

Julie Reed leads the IBM Lotus Foundations engineering team. She has over 25 years experience in the software industry spanning various application server environments and collaboration platforms. Julie came to IBM with the Net Integration Technologies acquisition in 2008.

Larry Menard

Larry Menard is a Quality Assurance Team Lead for the IBM Lotus Foundations products. He began his career with IBM in 1979 and has held a wide variety of positions within the company. Prior to joining the Lotus Foundations team, Larry's most recent positions included Quality Assurance and Information Development for the IBM DB2 relational database product.

Register at while space is available


| | TrackBacks (0)

I just had a complete Jaw drop.  Another Teaser



“TRON”, one of the very movies that gave me that gentle nudge into Geekdom.


“TRON” Legacy is making it’s way towards theatres.  Another Trailer released. 





Are you a Developer?  Interested in Code?  Do you Live Sleep and BREATHE in nothing but Binary?

Do you friends find you huddled in a corner of the house drooling over the latest .NET libraries?

Do you REALLY have to think hard about whether to spent your money on a new compiler or your wife?

Did you DROOL all over the table when somebody said “AZURE”?

If this sounds like you, you REALLY need to sign up for the Toronto Code Camp!

It’s a Free All day event held on a SATURDAY!  A Perfect excuse to leave your wife and kids behind


“…I’m sorry honey… *sniff* … but I HAVE to go for Training … *sniff*…”


Details are STILL up in the air for what sessions will be there but it’s GUARANTEED to make Developers ‘W00000T!’ and ITPros run in terror.  (Unless they Script in Powershell, in which case they might only cringe)


CODE has never been this fun!



Watch for Details on

Be there or ADMIT you know how to calculate SUBNET Masks!

Saturday May 1st 2010 – BRING on the DATA BONDAGE!


Within Windows 7 / Vista and Server 2008 / R2 there is a set of Event logs.

Not the “Classic ones” we are used to but a whole new Class of of logs that can be expanded on simply called the Windows Event Logs.

You can access their contents in Powershell using the GET-WINEVENT CommandLet in the following fashion.

GET-WINEVENT –Logname Setup


GET-WINEVENT –Logname ‘Microsoft-Windows-WindowsUpdateClient/Operational’


To get a list of these logs that are available you key in


for a complete list or you can type in Wildcards as well such as


For all those Starting with the letter “S”

But oddly somebody forgot an important CommandLet … the one to CLEAR the logs!

Now they can also be managed from the Command prompt using WEVTUTIL.EXE which works very nicely.  But we people in Powershell land like to keep everything on the same page.


So thanks to Shay Levy for pointing out the proper Acclerator and technique, we now have a NEW commandLet we can add to Powershell.   There are a number of ways to bring it in, the choice is yours.

I could do it as a Module but I got lazy today and just opened up my $PROFILE for Powershell and added it in.

Here’s the code so YOU TOO can “Share and Enjoy” as the Nutrimatic would say.


Function Global:Clear-Winevent ( $Logname ) {

Given a specific Logname from the GET-WINEVENT Commandlet
it will clear the Contents of that log

Cmdlet used to clear the Windows Event logs from Windows 7
Windows Vista, Server 2008 and Server 2008 R2


Get-WinEvent -listlog * | foreach { clear-winevent -logname $_.Logname }

Clear all Windows Event Logs

This is a Cmdlet that is not presently in Powershell 2.0
although there IS a GET-WINEVENT Command to list the
Contents of the logs.  You can utilize this instead of
WEVTUTIL.EXE to clear out Logs.  Special thanks to Shay Levy
(@shaylevy on Twitter) for pointing out the needed code





Thanks a bunch Shay! We owe you BIG! :)

the Energized Tech

Certification as an MCP, MCT sets a bar for others to not only Aspire to, but sets a standard employers can work with.

There are many certifications out there that beautifully serve this purpose.

But there is one lacking.  One for “Scripters” or I like to think as “Environment Automation”

There is some rumbling that stirs up whenever it is mentioned in the Community.   Powershell scripters crave for it.   There is nothing right now that sets the bar.

But I’m thinking a lot more specific on “Scripting” or “automation” as a skill set that ENHANCES what an MCP is.

Some people in Microsoft think it’s ok that Powershell or vbScript is touched on lightly in the Certs as part of the exam structure.   But that isn’t the case.  Having had to start implementing these techniques in my most recent position I recognize something truly important.

A person that understands automation as a specialization is as EQUALLY as Important as having somebody who knows how to Architect the system.  But not knowing whether an Administrator is qualified on some level makes it difficult to gauge those abilities.   And in today's Economy, Employers are going to want EFFICIENCY.  Not so much to get more done, but to get that “More” done quickly, effectively and most importantly CONSISTENTLY.

Proper automation and the ability to leverage those technologies (and more importantly WHICH ones) changes a Network Administrator or Systems Administrator from a simple manager that can get things running, to a key technologist that can spend more time looking into long term solutions on the Infrastructure.   Knowing how to deploy these technologies in a more Automated and Seamless fashion on a day to day basis allows for a much greater level of consistency than somebody that lightly touches on Powershell, vbScript or GPO.

But presently there is no way (other than field use) to determine what Level a potential Administrator is.

And so I propose this.   I propose Microsoft Development AND Microsoft Learning team up together to promote the creation of a New certification.   It may not set aside the individual as an actual MCP but it SHOULD complement existing certifications (IE: MCITP or MCTS in Server) to identify the Individual as a competent “Scripter”.  Competent in a good range of Technologies, GPO, Powershell, vbScript and classic Commands.

With this type of enhancement on a certificate (As a separate Single Exam) Microsoft could identify individuals that not only know the server for installation, but are ESPECIALLY qualified to maintain those systems.

Such an exam would involve more simulation or practical application questions.   Such a certification would help employers identify people best suited to manage their networks in the most Efficient and Consistent fashion.

And so to you, the Community.   The IT Professionals, the Scripters, the Powershell Experts, the GPO Gurus and all Future Network administrators, I send you a task.

I have been told, if we can get the attention of Microsoft corporation, and more importantly, Steven Ballmer’s attention.  Something could happen.  We have to ring the bells LOUD

So we as a community need to contact directly.  Do NOT spam him.  Take two minutes (or three) compose and EMAIL and put in the TITLE of that email ATTENTION: IT Community Demand for MCP Certification in Scripting and Automation Technologies. 


Our target is no less than 5,000 emails.  I want to see it happen.  We can do this.  vbScripters, Powershell, GPO, Command specialists.

And it all starts with us

The Energized Tech

One of the big reasons people would back away from NTBACKUP was Server 2000.   It’s a great simple utility but it didn’t have ONE REALLY IMPORTANT feature.

Open File Option.

The Open File Option (What Full Veritas BackupExec had an a $1000 Add on) was the ability to backup files that were in use.   If you had important Word documents or a particular Quickbooks database open, they wouldn’t backup.

Then along came Server 2003.  Server 2003 introduced “Shadow Copy” which was actually a technology which contained a built in “Open File Option” that NTBackup just used.

Some people didn’t realize this! 

Yes, if you’re a small Business Owner looking into options for Backup and you don’t have the budget for Veritas Backup Exec, NTBACKUP is a viable option now.  Even if you’re a large Corporation, the fact that you can leverage a solution to backup those open files WITHOUT incurring additional cost is a great boon.

Now I am NOT knocking Veritas Backup Exec.  It is NOT an overpriced boondoggle.  It IS the BIG BROTHER to NTBackup.   It logs in GREAT detail how to the backup ran.  If even ONE file does not backup, Veritas considers the backup a fail so you’re on your toes.   Veritas will make your Backup far more compliant for SOX with the built in reports.

But keep in mind that if you have a Server 2003 computer (or even Windows XP Pro!) that built in NTBACKUP can backup your open files.   I’ve even seen it backup Exchange 2003 Databases with Open File

Now THAT’s Power! Free Power to “Boot”

The Energized Tech

As anybody knows me, I consider myself a “Scripter”, a creature not quite ITPro nor Dev and as such, a halfling from both words.

In short, I a “computer Hobbit”.

Scripters work in a world of Automation, in an attempt to make their jobs more efficient by PROGRAMMING repeated tasks rather than “click click clicking away” into Tedium Hell.

When you step into the world of Scripting and Automation you will probably find one solution you’re comfortable with, whether it be Powershell, vbScript, Group Policy or even the venerable and Classic Command prompt.

And you may (Like I did) have a tendency of Guardedly sticking to ONLY ONE solution and doggedly refusing to look at other options no matter what happens.

But the thing to keep in mind, why did you get into Automation?  Was it to make your job more difficult? Of course not!

So, when DO you look at other solutions?

Honestly it’s a little combination of “What are you comfortable with”,“Just how much time *DO* you want to spend at it” and “Are you spending the extra time to LEARN for fun or just out of dogged frustration”

I am reasonably certain that if you sat down, dug through the internet, you might find a solution for just about everything you can in Powershell (not all but just about) within a Command Prompt.   You could also go completely bonkers trying to ensure everything works via vbScript.   Or you could go Powershell nuts and try to become a .NET developer overnight and do everything in oneliners.


But in this mad process, you often overlook some excellent and very obvious solutions.  And there are situations where you can leverage multiple solutions against each other.


So here’s what I do.  I have one “Axe”, one solution I am comfortable with. Powershell.  I LOVE working with Powershell.  If it feels enjoyable to find a solution in Powershell because it’s fun or challenging, I’ll do it without question.


However again, there are tons of prebuilt Command prompt applications, Group Policies and vbScripts I can leverage.   For me, sometimes I’ll try to see if there is a WMI solution already existing in vbScript and try to port that to Powershell.   There are situations that NETSH makes far more sense than reading the registry to get an IP address along with many other built in goodies.   Using GPO makes more sense many times to deploy or remove rather than running from logon script.

My overall opinion is this.   Learn. 

Learn what makes YOU more productive.  Don’t tie yourself into a box saying “I can’t” because your “main Axe” doesn’t easily do it.  Don’t be afraid to see if there are more than two solutions to a problem (There often are).  Sometimes in learning a different solution as well, you may find a way to produce the answer in what you’re comfortable with.

Remember.  Computing should be fun, try to keep it that way whenever possible.

And the job, should always feel less like a “Job”

The Energized Tech


I opened up Pandora's box and found more goodies! 

Did you know you can easily Enable and Disable Monitoring on your Windows drives with Powershell?  the same feature which offers “Shadow Copy restores” ?

By default it’s normally enabled on Drive C:, but let’s say this is a Server Environment.   You deploy them on a habitual basis, and like any good IT Pro, you keep the DATA from the SYSTEM.

But out of the Box, anything other than C: does not have system Restore enabled.  So normally that means, GUI, Right click, find option… AIGHAHGAHHHGA!!


But not with Powershell

In Powershell it’s just run as Administrator and






So if you’re running a Domain Controller by default you might want to shut off the Volume tracking feature because you DON’T want “previous versions” available to alter your SYSVOL structure.  That’s just a mess waiting to happen.



And if all of your data is sitting on the new Drive E: and needs to be monitored so you CAN do “Previous versions”



Your work is done! Now relax and break out the bubbly!

The Energized Tech

Part 1 – Hello Free backup, I never knew you so well

In a previous life I spent my days working with clients and using the native backup solution from Windows “NTBACKUP”

Now a lot of people look down upon NTBACKUP as the poor man’s backup.  Stripped down, hurt.

Let’s take a second look at NTBACKUP.  In Server 2003 with NTBACKUP you had the following features

Licensing cost – NIL (Free to use with the O/S)
Open File option – Built in (Yes, thanks to Shadow Copy you can backup many if not all open files)
Exchange agent – Built in
Media supported – Tapes and Physical Media
Ability to Email logs – programmable

You have to remember that “NTBACKUP” is really just a stripped down version of BackupExec (owned by Symantec now) and really ISN’T that bad of a backup.

You can run it from a command line, the configuration files are pure text (and easy to edit) and if you leverage just a few of the features built into Windows you, as an Administrator can have a backup system capable of emailing, printing and archiving logs.

“But I have an SQL Server!” (I hear a voice in the background scream)

And SQL has it’s OWN built in backup which can be scheduled and will co exist with NTbackup.

So feeling a little less nervous? Good

Follow along with me as I try to lightly touch on leveraging the built in Backup solutions provided by Microsoft to extend your abilities and pad your wallet with savings.

The Energized Tech


Hey did You know you can create a System Restore snapshot in Powershell ?

I didn’t until five minutes ago.  The Cmdlet name wasn’t one of the typical “GET” or “SET” ones,as such I missed it.

But I ran a GET-COMMAND this morning looking for some interesting CmdLets to learn and saw this one


And it’s about the easiest one to run!

CHECKPOINT-COMPUTER –Description “This is My System Restore Point”

It has to be run with Administrative Privledges and produces a nice simple status bar as is executes.

What does this mean to you?

That no matter what you do, you have an EASY way to trigger a System Restore Checkpoint.  A simple shortcut to a Powershell script to run it and cover your bases.


Powershell, stressfree for you

The Energized Tech

Scripted My Way

| | TrackBacks (0)


This is dedicated to ALL scripters.  Anybody including vbScript, Logon Script, Shell Monkeys, Powershell Dudes whatever you want to call yourself.

Scripting is a passion to those that do it.

And to you, Sing this to Frank Sinatra’s “My Way”

I Script it My Way

And now the Server's Off
The Switches Blink within a green glow
I need, to launch it now
But it's locked away behind Medeco

I'll use a Wake On Lan
In Powershell, I'll launch and then play
No more, won't pay for code
I'll script it My Way

And with, my vbScript
I'll go and warn of interventions
My logs have triggers too
They tell me now from my inventions

I carved and shaped them all
I automate my work for my pay
An ITpro and yet I Code
I'll script it My Way

Oh there were days, I wished I could
Whip out a Visa now, I surely would
But rather than give in to Hell
I'll code it in with Powershell
And vbScript and Batch Files too
I'll script it My Way

I speak in Syntax now
ItPros, they don't know me
And Devs, they shun me too
My code it runs so very slowly

But I, will not shy on down
For I stand proud of my automations
For I, I did it all
I Scripted My Way

For what is code no matter small
Whether a function or simple Call
To automate in Joy and Glee
I’ll do it all Enternally
The systems bow and move to me
They're scripted my way



In Powershell there is a VERY use to feature that many of us didn’t touch (*especially those of use NEW to Powershell*)

It’s called your “Profile”

The Profile is just settings and Functions that are SPECIFIC to a Powershell session.  Most of the time you will see them in use by software such as “Quest ActiveRoles Management Shell”.  When you see “Custom Management Shells” such as the Exchange Server 2007 and DPM Shell, those are just really customized profiles for the most part.


So how can YOU make a profile in Powershell that meets your daily needs?

Very easy in fact.   You won’t be surprise either, it’s dead simple too!

Your personal profile be default does not exist BUT the variable to point where it is DOES.  All YOU have to do is run this simple command


And you now have a blank profile.

By launching NOTEPAD $PROFILE you can edit it and add useful features to your Powershell session.

For example, is there a particular script you use DAILY or functions you would like to have native your Powershell session?

Turn them into Functions in Powershell and add it to your profile.  It’s as simple as copy paste!

Do you have going between Quest and Exchange 2007 and would like it all as ONE shell?

Put the ADD-PSSNAPIN for each feature as the top lines of your profile.

How about something as simple as “I want my Shell each and everyday to greet me with a Cheery HELLO!”

Well you can do that to! Make the last line (or the first as you prefer)

Here’s a sample profile so you can understand the syntax.  It’s not really any different from a PS1 file, in some ways it’s a LOT like a PS1 file that runs on the startup of Powershell

----------------- Sample Profile -----------------------

# Add Snapins

ADD-PSSNAPIN Quest.ActiveRoles.AdManagement

# Say Hello to the nice person

WRITE-HOST “Hello and Goodday to you Glorius Administrator”
WRITE-HOST “I am your Powershell Administration Session.”
WRITE-HOST “Your wish is my command”

#Define a useful function

function global:OUT-HAPPYMESSAGE {
WRITE-HOST “I am the King of my Universe, all shall run away from me…”

#Make an Alias


----------------- Sample Profile -----------------------


So with this very simple profile My Powershell session will now start like this


As you can see I now Have a new Custom function called “OUT-HAPPYMESSAGE” I can run anytime to make myself feel good and mighty.

I can now Open Files and launch their respective applications.

I can also access my Quest Commandlets and be more Productive and leave work earlier and go…… I mean MAKE THINGS FASTER SO I CAN WORK HARDER! (did my boss see that?)

All in all not difficult to use, to change or to share (As it’s just a text file under the

%USERPROFILE%\Documents\Windows Powershell\

Folder that you can copy onto other systems as well.

Powershell, Live the good Life for free


The Energized Tech


I was helping out in the forums when a Question popped.

“Can I programatically disable a Network Card?”

The gentleman had a system that would have Full Domain access (for regular users) and occasionally somebody would need to work on the machine as a Guest and be guaranteed to have no Network access.

Although there are many things you can do to REALLY restrict network access; Hands down NOTHING beats pulling the LAN cable!

So doing it via software?

Turns out with WMI it’s VERY easy.  You just need to run as Administrator and execute the following command.

GET-WMIOBJECT WIN32_NETWORKADAPTER | foreach { $_.Disable() }

which will shutdown *ALL* network adapters (Physical, Logical, ALL! or

GET-WMIOBJECT WIN32_NETWORKADAPTER | foreach { $_.Enable() }

to Enable them all again

You CAN get more specific and isolate that to only physical adapters by adding in a WHERE-OBJECT filter like this since the WIN32_NETWORKADAPTER has a property called “PhysicalAdapter” which is Boolean “True” or “False” on whether it’s a “Physical Adapter”.  

GET-WMIOBJECT WIN32_NETWORKADAPTER | where { $_.PhysicalAdapter –eq $TRUE} | foreach { $_.Disable() }

to only shut off Physical Adapters.

It’s not a typical scenario and this CAN be done with VbScript too if you prefer by using this script for the Blanket approach

----------- Disable All Network Adapters --------------
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter")
For Each objItem in colItems
----------- Disable All Network Adapters -----------

But honestly for just DEVELOPING the vbScript portion of it Powershell was STILL the King since it allows me interactively test and work with WMI with “open notepad, edit, save, run, curse, do it again…”


Powershell, making life easier one Cmdlet at a time

The Energized Tech

First statement, I have nothing against the Office Live Add-in, it’s a great feature.

But if you don’t use it and need to easily disable it network wide.  Quickly without going computer to computer to computer and clicking on “Disable Addin” option?

Here’s how. 

Like just about everything, the settings are sitting right inside the registry.  Just a matter of editing them.

The addin sits near where the rest of the Word addins sit.  Right off of


If you’re working with a 64bit environment (because it IS a 32bit application) you’ll find it sitting under



In either case, the one setting you need to change in the registry to disable the Addin is simple “LoadBehaviour”.  Changing that value to a 0 will completely disable the Office Live addin in Word 2007 for all users. 

Now because this is a registry change you can just script, GPO, flash the change at will.   So much easier than “Login, Disable Addin, Logoff… Grumble…”


The Energized Tech


Within Powershell there is a very powerful and yet simple to use feature.  The ability to place helpful information and documentation within your scripts and functions.

You’ve already seen the results of it in use.  When you type in HELP and a CMDLET


Which usually reveals this typical screen.


So you can leverage the HELP system when YOU make scripts too!  It’s call “Comment Based Help”.  If you type

HELP about_Comment_Based_Help

You’ll get some well written instructions from Microsoft.

So here is a sample Powershell Script that does nothing other than do a “Hello World” to the console


OUT-HOST ‘Hello World’


Now if we save this file as HELLOWORLD.PS1 and try doing HELP HELLOWORLD.PS1 all we’ll get is a single line that says


To put some help into this just drop in a “Comment Block” with appropriate keywords (documented in the Help files) to fill in the “HELP” Details

A comment block begins with a


and ends with a


For example we have various keywords such as


There are others, but we’ll add in these to our file so you can see you could add in the HELP

------ HELLOWORLD.PS1 ---------


This is a Powershell Script – It is simple

The Script you have when run will produce Output on the Console that says
Hello World.  It will do nothing else.  It will not sing, or do pretty lights, it will
not break anything.  All it will do is print TWO WORDS on the screen.  And only
the words ‘Hello World’.  I know, it is a lame script.  I am sorry.


Output on Screen
Hello World

I would love to have some really impressive notes in this field, but since the
script is so lame the only Notes I can put in are
Pick up some Milk
A loaf of Bread
A box of cookies



WRITE-HOST ‘Hello World’

------ HELLOWORLD.PS1 ---------

Now when you type in HELP ./HELLOWORLD.PS1 you’ll get THIS output


And yes, it does support the standard extensions to HELP like –full, –detailed and –examples .  You won’t see the .NOTES from Help until you do a


Afterwards you’ll see this and the Website link I dropped in for further “help” :)


It’s not required to do this, but it does add a huge level of professionalism to your scripts and even makes it easier for Subordinates to know that anytime they’re in Powershell just type HELP and a Cmdlet or function to “GET-HELP”

Powershell, It is Easy

The Energized Tech


A quick and dirty one for you.  There is often time I need to launch and edit a word document in Word.

And I’m lazy.   I try to work from the Command prompt as much as possible.  Type it and I’m good.  I just hate clicking that darn mouse whenever possible.   The more I live in Powershell, the better and happier I am.

I constantly open .CSV files to view and search the contents in Excel.  I find Excel (and other applications suited for that exact purpose) do the job beautifully.

I didn’t realize until just now that if I launch “START-PROCESS” and a filename.CSV or .DOC (or whatever) it would just launch the default app with the file loaded!

I like that!

But, as I said before.   I don’t like typing.  So I made an ALIAS and you can too.   Think of an ALIAS as a keyboard shortcut.   Something to make you more efficient.

The process is easy too.




So super lazy me made an ALIAS to “Open files”


So now in Powershell I just type in “OPEN-FILE THISFILE.CSV” or “OPEN-FILE SOMETHING.DOC” and it launches the default app with the file opened.   Yes, this is good for PDF files too.


And yes, you could just as easily as lazily create an ALIAS call “O” to “Open a file” :P




Powershell.  Enjoy the sweet life.

The Energized Tech

I had friend call up.  A guy who REALLY knows his stuff.
Occasionally I fall down and prostrate before him for fun.
Anyhow, he went to pass some parameters to a batch file.  And no matter WHAT he did a blank space went at the end.
Yes, a Single @#$#@?@!?!?!@$ Blank space!
The code was correct.   It was flawless, it was perfection.
But this @#%#@?!!#$?#@! Blank space kept appearing in the content.
So he calls and asks, just cuz.
I look at the phone like he's an idiot (which he isn't).
I type the code manually on my side.  Nope doesn't do it.  He emails me a copy of this ORDINARY Cmd prompt Batch file.
And EVERY #_%!_$ you run it, the mysterious "Blank Space" appeared, teasing and taunting us like a foul beast.   So I'm online digging up for glitches, undocumented features, bugs and he calls back
"ARRRRR!!!!! Ye know what is was ? Arrrrr!" (He says all piratey for know reason....  None that I could see.
"ARRRRRRrr!!!! 'Twas the Wicked White Space come to haunt me to my grave! Arrrr!!"
White space?
For those of use that remember "DOS" White space is Technically a character that EXISTS within the ASCII set but does not translate on the screen.  And yes, like it's name it IS a space.
And how do you kill that foul beast?   Well not with Notepad since it actually will live and HIDE in Notepad (being that it is a valid ASCII character.  It will hide like a Scorpion ready to strike you down.
What's the fix?
"Arrrrrr!" My Frozen Piratey Hardware BetaTesting Friend"Arrrrr ye have t' Use Notepad++, show's the wee creatures! Turn on "View, Show Symbol, Show all Characters" Then ye trap 'em and SQUISH 'EM and ERASE them from the EARTH!! Aharrrr! Ahar arharrrrr!!!"
I see.
And so True enough.  Reexamining his Poison batch file revealed those dastardly hidden white spaces.
So remember this, if the non sensible happens?   Look at the Text file from different software.
Or errrr...... just "Voluntold" somebody to type it in clean :)
The Energized Tech
"White Space Free since 1984!"