My Long Road to Redmond–Part 1

I awoke this morning with a start.  4:30am without an alarm clock I bolted upright.   So sudden I almost fell out of bed backwards as my roommate Cory watched with a sudden chuckle. 

That stark unstoppable realization rapping away at me.

I’m in Seattle.  Seattle, Washington.   I’m a very stone’s throw away from “the Mothership” as it is nicknamed.  Microsoft’s Head Office.

I would suspect there is a lot I can’t talk about.  For that I won’t breach any confidence.  But I can at least type and express what I am feeling.

I am feeling elated, inspired, and more Energized than I ever have in my entire life.   The mere thought of stepping through the gates of Redmond and just meeting the people and technology has put my brain into a spin I am having a very difficult time describing. 

It’s what has had me wide awake every single day at 4:30am, bolting upright without the alarm clock.   The energy of Redmond, Washington seems to be calling me.

Others smile and might think “Silly Sean” or may nod knowingly as it has the same effect on them.  I don’t know, but I can only say what it means to me.

It’s a dream come true.

Several years ago I decided it was my one goal to work for Microsoft.  In striving to reach that goal I began to change, and almost evolve.   Evolve seems to be the most accurate word.   What started that?  Microsoft.

I met the people I looked up to as heroes back in 2007 at a conference called Energized IT 2007.    One of these people looked over at me and said “Oh my God you’re just like us!”

Part of me almost fainted that day, but another part lit a spark I had never felt before.   It brought forth confidence I had never known.   I decided to be creative and start to make mistakes, write and sing songs (Yes, I admit it.  I was a former Friday Funny Guy and I will never dread that) and just blog, not worrying about whether what I did was good enough for anybody else.

That courage led to writing a Theme Song called “Thundergize” for Energize IT 2008, becoming a speaker at Techdays 2009, a Session Lead at Techdays 2010, and more that’s about to happen.

It led to me getting involved in the Windows Powershell community.  Engaging people that, prior to all this I marked as “the Computer gods”.   I became more willing to open up and say things, sometimes be wrong but LEARN.   Yet here is the neat part.

I didn’t change.   In truth, this was always in me but I lacked the courage.  I just didn’t believe in myself.   Now parts of me that were always there are bubbling and surfacing to the top.  My Energy levels seem to rise the closer I get to Microsoft and Redmond, Washington.  It is drawing me like a magnet and I do not want to walk away.   I need the inspiration that is Redmond and will not look away from what it does to me.

This both amazes and frightens those that know me.  I am a very Energetic person when you get me going on Technology.    Friends will attest to that.   The term “Release the Kraken” was coined when that excitement about technology hits it’s peak.

Which has people I know a little worried.   When I stand on the grounds of Redmond, Washington; “The Mothership”, the very place where some of the greatest minds INCLUDING Bill Gates, Steve Ballmer and Paul Allen have stood.   They wonder “What will happen?”

Will I “Bow down at the gates and kiss the ground?”

Will I “Release the Kraken and lose myself emotionally?”

Will I just faint?

No.   I will evolve as a person on a new level.  I don’t even know what it is.   But I look forward to just standing there in Redmond.  Soaking in the inspiration.   ?Letting her mold and shape me to a new level.

I look forward to the next 5 days.

There is only one problem I foresee.   I may find myself not wanting to go home. Winking smile

The Energized Tech

The 2011 Scripting Games are COMING YOUR WAY

dr-scripto-2011-Soul 50

It’s time to Unleash the Power of Shell.   Pull the Scripter from within yourself and stand up and show your stuff!


On April 4th to April 15th, the 2011 Scripting Games are coming your way with all the uncontainable excitement they hold.


Do you think yourself a Scripter? STEP up to the plate!  But there’s also stuff equally as fun for the Novice at heart as well!

The Scripting Games are just as much about Enjoying yourself as they are in testing your skills.


Read up more about them on “The Scripting Games Study Guide” , Follow and “Hey Scripting Guy” for more details.   Or if you’re on Twitter watch for the Hashtag #2011SG for details!

In the meantime, let a little inspiration burn at your fingertips from a little video inspired from the Scripting community Smile

The 2011 Scripting– Powershell Unleashed

Combining Powershell and Sysinternals–Closing a File Handle


An interesting question came in Friday during the Webcast on Technet Talk Radio.   What I thought was “Huh, yeah you SHOULD be able to pull that off in Windows…”

“Is there a way in Powershell to close a file handle?”

I decided this morning, that was bugging me.   So I started digging into the Developer Land on MSDN to try and learn something.  That made my brain hurt a bit.   After a did a quick search on Bing for the obvious.  Maybe somebody had already built a tool to do this.

Wouldn’t it make sense the coolest bunch of Geeks at Sysinternals would have done this already?  YUP!

The tool is called “HANDLE” and you need to run it as an Administrator (So I imagine running it as SYSTEM should have the same rights if I had to schedule it)

HANDLE works very simply.  Key in HANDLE and the file you’re trying to close, it will yield a pile of info including the Process ID calling it.   It will also output the Hexadecimal ID the File is associated with.

Download it and run it at least once beforehand (To accept the EULA) and you’re good to play

Here’s the catch.  Standard Administrator?  Perfect.   I’m closing a handle, I manually run it.  But today we’d like to automate it. 

So our FIRST challenge is getting the output of HANDLE into Something Powershell will use.  That’s easy, LITERALLY grab the Console output.

$DATA=(& “C:PathToHandleHandle.exe” filesomedummyleftopen)

So now we have a Big pile of Data stored in conveniently a variable called $DATA.  Fortunately for us our good friends at Sysinternals formatted the output of HANDLE into CONSISTENT columns.

So the first 5 rows in our array we can ignore.   That’s the header from the output in HANDLE.EXE.   How do you tell? You can step through it Piece by piece like so




Handle 3.45


Copyright (C) 1997-2011 Mark Russinovich


Sysinternals –



See? Now our FIFTH line is where the goodies start showing up.  It appears a “Certain ItPro” forgot to close off a Word document.


WINWORD.EXE        pid: 7912   type: File           7D0: C:Userssean.kearneyDocumentsSample.docx

*cough* oops.

The nice part with this output is we only need TWO pieces of info, the PID (Process ID) and the HEXID for the file handle.    The nicer part is since all of this is CONSISTENT in it’s formatting.

I found the PID Number always starts at column 24 and is never more than 7 bytes long.  

The HEXID could be more than what I see here (3 bytes) but the area IT takes up is ALWAYS the spot before the file name and ALWAYS after the word “File”.   Turns out THAT is starting at Column 41 and never more than 14 Characters.

How did I find this out? I’ll be honest.  I cheated.  I kept doing this and changing numbers



Which shows you all information from position 10 down or position 20 down.  After I went in and keyed in



Which shows you all the information from position 24 down and then only 1 character or 4 characters.   It’s not “Geeky cool” but for a new Powershell Admin, knowing how you could navigate the data can help.

So what does that mean to us?  Consistency and a pattern we can work with.



So great I HAVE the information and I’ll just pass that right back to HANDLE.EXE to close the file handle.

But wait.  We forgot something.  There might be blank space in that text.   We want JUST the information, no blanks to screw us up with Delimiters! *ARGH!* Sean !  You lied to us!  You said this was going to be easy!

Well, that’s doable to.  Just a little more trickery in Powershell.   We can use what is known as the “Trim” method on a string to “Trim” the blank spaces off either side



So now ARMED with this information we can just call HANDLE.EXE from Powershell.exe and

(& “C:PathToHandleHandle.exe” –c $HEX –p $MYPID -y)

So how is this efficient?   If you play with Handle it can do “wildcarding” on Paths and files.   If you have a particular file structure on a FILE server that users are forever leaving Excel documents open?  Backup can’t get to it?  You can NOW use Powershell AND Systinternals together to create an even more powerful tool.

You’ll also note that I only referenced Element [5] in the array.  If I wished to step up one more level and have ALL of the files revealed by HANDLE.EXE closed, I can just do this. (But be careful on your targeting!)

# Get the console output of HANDLE.EXE from Sysinternals into a Powershell Variable

$DATA=(& “C:PathToHandleHandle.exe” FolderFullOfStuffLeftOpenByTheSillyUsers)

# Get the count of lines in the output

# Remember, the good stuff starts at line 5
Foreach ($line in  5..$Count)
      # Get the Process Id for each file
      # Get the Hexadecimal ID for each open file
      # Close that file!      
      (& “C:PathToHandleHandle.exe” –c $HEX –p $MYPID -y)


This is why I love Powershell.  I do NOT need to throw away perfectly good tools just to use Powershell.  I can leverage BOTH, like the amazing Console based tools from Sysinternals, at the same time and sometimes come up with solutions I never could easily conceive of before.

Remember, the Power of She
ll is in YOU

the Energized Tech