September 2010 Archives

Today I had to provide a simple solution.  Create a formatted text file from two inputs from a user.

There was no time to have Development build an application and it literally WAS a simple app.

Get two variables, write them to a formatted text file.

So Why NOT do it in Powershell?

In all honesty, Powershell would have been easier but I needed something that could be converted to ASP.NET later on (if so desired).  So I played with vbScript for my first time.  I mean REALLY wrote something in vbScript.

First off, I think my code was poorly written and could have been easily optimized.   But it wasn’t hard.  It was a little different from the Syntax of Powershell but not horrid to deal with.   I did learn however (after having sat down and done it) just why I prefer Powershell.  That lack of need to Predefine every variable was one.

Perhaps I’ll get into some functions next time with vbScript.   Really, both languages support many of the same mechanisms.   Maybe if I optimize my vbScript code it will feel a little more like Powershell.   

But it was nice to code in another language and not find it so horribly different.  

Flex your creative muscles, you’ll be surprised what you can do.

Sean – The Energized Tech


A fated day in 2008, I wrote a single Blog post about Powershell called “Highway to Powershell”.  It was simple thing.  A fun song I wrote.   Something I did in a time when I was known as a “Friday Funny Guy”.

A simple post that sent me down a path.

Powershell.  Not just the technology but a community of some of the most interesting, intelligent and passionate people I have ever met.

It started with me looking at the stats for the post, which on a good day would have been 10 views a day.  As you can tell I had a quiet little blog.  That day, things got a little “Scary”

500 views in one days.  600 more after that.  I tracked back the posts and found some fellow name “Jeffrey Snover” had viewed, commented and posted it to some “obscure blog” on

“Can’t wait for the Youtube video” was one of the comments from him.

It spawned into my first ever attempt at singing and Youtube and Videos.   The lyrics carried forward into this new and unknown community of people of Powershell Enthusiasts and experts.   The Lyrics became used in at least two huge Microsoft events, Energize IT 2008 and Heroes Happen Here in Norway, the latter performed on stage by Ragnar Harper of Crayon.

“What have I done?” I kept thinking.  A simple song.   Why would it affect anybody?

Then I began to need to use Powershell, and used it, discovering why people would be so passionate about it’s use.  A Unified Management Scripting solution across various Microsoft and 3rd party vendor platforms.  A solution that could be as simple as a Network Administrator would need but had the unlimited power to be built upon and leveraged by Developers.   A technology that would still retain the ability to leverage existing scripting solutions from vbScript and CMD.

I had stepped into the world of Powershell, a world that helped ITProfessional and Developer find a common ground.

And so today, I release back to the Community I have come to love, a final release of “Highway to Powershell” with the very music Ragnar did on stage combined with a video holding tribute to the Community, the MVP’s and actually using Powershell to sing and even play a guitar.   I will post that script in a later post.

I <3 Powershell and the Powershell Community

By the way, as after note.  the Three characters in the picture below you?

Myself (on the left)

Dmitry Sotnikov from Quest (Rear)

Ragnar Harper – Kick ass guy and passionate about technology from Crayon in Norway.

Three guys and now friends, from different lifestyles and different countries unified by one technology



Bonus of the week!  In LESS than 13 DAYS Techdays 2010 for the first time ever will be held in Edmonton, Alberta!

Edmonton!  Home of the kick butt Edmonton Oilers, killer Stanley Cup champions and home to Champion IT Professionals!

I get to present not one but TWO sessions and I hope to see YOU there!

I not only Excited but ENERGIZED about Techdays 2010 in Edmonton !

If you haven’t registered yet?  Don’t miss this opportunity to be at the first edition in Edmonton of the GREATEST Event in Canada!

Techdays 2010.  I’m honoured to be a part of the first of it’s kind in Edmonton.

Hope to see YOU there and change your day for the better !

The Energized Tech


A long time ago in a land VERY far away Techdays two friends and An ITpro and a wanna be Developer dared to venture down the path of enlightment towards reason.

That was two years ago.

I thought it would be good to share to complete entire TWO EPISODE series just for fun.


Are you interested in finding a FASTER and more efficient way of deploying Office 2010?

Check out this Turbo Talk being held at all the Techdays 2010 events across Canada.   Find out quickly and efficiently how YOU can deploy Office 2010.   Automated deployments work on Open License, Retail and OEM.   See the experts and learn how in clear terms.

Just Register for Session DPL231 – Automating your Office 2010 Deployment and immediately walk away with techniques you can deploy in the field and get ahead of your competition.

Get your brains gassed up, kick in the Turbo, Register at and learn all you can learn.


What do you envision for deployment?  Do you picture problems and uncontrollable issues?  Legacy documents that won’t convert?

Check out Session DPL 301 at to learn how to control and mitigate those issues.   Free Application Compatibility tools from Microsoft you can use now in a safe and non intrusive manner to not only identify but control, and in some cases eliminate your issues.

Don’t fear “The Morning After” – Check out Session DPL 301 and learn how to easily control all the issues and look forward to deployment.

If you’re lucky, you may even get to see a long lost friend as well during the session


I caught this one in Twitter yesterday.

“Is there a way to remove Blank Lines from the output?”

Top of my head I could think of an –EXCLUDE option for blanks but it isn’t hard to identify and remove blank lines from Text content.

So today’s task class is we’re going to use Powershell to erase Nothing.


Well actually what we’re going to do is get rid of Blank lines from text files.

It’s pretty easy really.

When you read in the Content from GET-CONTENT it actually ends up as an Array of text,  meaning you can select and examine each line individually, including the number of characters.

So for the million Dollars, Dinner with Bill Gates, a signed autograph from Steve Ballmer with love *AND* a pat on the back from Paul Allen…… guess how many characters in a blank line?

None, 0, Zilch, Nada.  The CR/LF (Carriage Return line feed is used as a Delimiter and does not remain in the Array)

So when we do this


$FileContent is actually an array.  Running a GET-MEMBER against it like this

$FileContent | GET-MEMBER

Will show us several properties including one important one called Length.  Length tells us how many members in that array (or in human speak, “lines”)

To access individual pieces of the array I execute this piece of code

For the first line


For the second line


For the third line


Seeing a pattern emerge?  Arrays start counting at zero.   Knowing that is important because although the Length of the array might be 30 lines, you’ll stop at 29 for the last one (since you start at 0 not 1)

On any one of those Array members you can also run a GET-MEMBER like this

$FileContent[1] | GET-MEMBER

andf view its available Properties.  Each line ALSO has a Length property.   This is how many characters in a line.   So to identify blank lines we simply look for Members which have a zero length.

IF ($FileContent[1].Length –eq 0) { WRITE-HOST “Blank Line”}

But in our case we’re going to skip those lines and build a new array of text.  Easily done, we’ll create a variable called $NewArray typed as an [Array]

So we get the Size of the FileContent array first and bump back by 1 (Since our last position of the Array to be access is the Length of the Array –1, we started at 0 not 1 remember?)


Then we setup a new Blank array to store the data in


Finally we run through the list with a Foreach loop, checking and returning lines that AREN’T blank, storing the built result into $NewArray.

FOREACH ($Position in 1..$End) {
     IF ($FileContent[1].Length –ne 0) { [Array]$NewArray+=$Filecontent[$Position])

Now as a script we would have something like this


$FileContent=GET-CONTENT C:\Somesillyfile.txt



FOREACH ($Position in 1..$End) {
     IF ($FileContent[1].Length –ne 0) { [Array]$NewArray+=$Filecontent[$Position])


And we would have a simple script to pull out the and display it without Blank lines.   Here’s the fun part, we want this useful.    We can make this a function to add to our modules and “Return” the results back to the user.   One easy change, watch the Before and After


Function Global:REMOVE-BLANK ($FileContent) {



     FOREACH ($Position in 1..$End) {
          IF ($FileContent[1].Length –ne 0) { [Array]$NewArray+=$Filecontent[$Position])
Return $NewArray



There you go!  Once defined in your profile or modules you can execute this code

$MyStuff=GET-CONTENT C:\Somesillyfile.txt

$NoBlank=REMOVE-BLANK $MyStuff

You can now do whatever you what with your “Blank Free” data.


See?  That wasn’t so hard!  The Power of Shell is in YOU, now use it! :)

The Energized Tech


Here’s YOUR opportunity for some free online training for Powershell Basics and to Ask the Experts “how to do it”

Register now on “The Edge” at Technet for a free session on Powershell Basics.

the Synopsis of the upcoming event….

Are there admin tasks you’d like to automate, but not sure how?  Do you want to learn Windows Powershell, but aren’t sure where to start? 

Send us your questions by emailing us here ( ) by Wednesday, September 15th , then join us for our LIVE TechNet webcast where we show how to use Windows Powershell to make your life easier.

Click here to register for the event!

Date: Wednesday, September 22, 2010
Time: 10:00 AM Pacific Time
Event Overview:

This one-hour webcast is geared towards IT professionals who do not have a strong coding or scripting background. We help you to understand the basics of Windows PowerShell, including parsing, piping, getting help, using variables and operators, and flow control. By the end of this session, you should understand enough to create simple commands and be comfortable enough to explore Windows PowerShell on your own.
Presenter: Peter Lammers, Lead Developer, Aeshen

Peter Lammers, lead developer at Aeshen, is an IT professional with a 17-year background in troubleshooting, training, modifying and supporting software applications, network administration, troubleshooting, and server and desktop support.

About Aeshen:

For over ten years Aeshen has been working with some of the biggest names in technology. In addition to our work with HP and Cisco we are preferred vendors for Microsoft and Intel in our core disciplines of web and application development, training and education, and QA services. This is in addition to the traditional types of deliverables we’ve historically done; developer and IT Pro focused content such as value props and marketing collateral, demos (online demos, click-through demos), labs, whitepapers, decks, and interactive vignettes for marketing and training.

For more information, visit

It Pro Toronto is back in session as of September 14th 2010!  Same location as last year, new schedule.  Second Tuesday of Every month!


Our next Monthly in person meeting is Tuesday Sept 14, 2010. Our topic is Database Normalization: When it is time to move your data from Excel to a database this is what you need to know.

Welcome time: 6:00PM
Start time: 6:30PM
Finish time: 9:00PM

Location: University of Toronto
Health Sciences Building
155 College St., Rm 106
Toronto, ON
South-East corner of College/McCaul.
West of Queen's Park subway station.

Speaker: Bob Scarborough
Integrated Visual Systems

Have you ever walked into a small business client who runs his business with Excel and has decided it’s time to go Database? You know the kind of client. His invoices are Excel Spreadsheets, his Customer Lists are Excel spreadsheets, his Product List – an Excel Spreadsheet. But now his business has grown to the point where he can’t manage this in Excel anymore. Updating the information is too difficult and it’s too hard to look up info across hundreds of Excel Spreadsheets.

It’s time to go Database and your client knows it. Perhaps Microsoft Access, maybe SQL Server Express. Maybe even SQL Server Standard.

No matter what software you pick, you have to be able to take all that data in Excel and reorganize it into Relational Tables. In DB speak this is called “Database Normalization”.

This presentation will describe the process in a way appropriate for an IT Pro dealing with Small Business Clients. (If you are a Database Administrator at a large company you will find this presentation to be kindergarten level but if you are an IT Pro who normally doesn’t do this kind of thing then you will learn the basics)

Presenter Bio:
Bob Scarborough is an independent software developer specializing in database applications. Prior to starting his own practice, Bob worked in both development and product marketing roles for several database software companies including Cincom Systems, Empress Software and Symix Systems.


A friend caught me on Twitter and was wondering if there was a way to centrally query computers in a network for their installed applications (more particularly in his case, a SINGLE application)

That sounded like a job for Powershell!

Now we COULD just use a GET-WMIOBJECT Win32_Product but that’s only good for applications registered via the MSI (Windows Installer)

So as my mouth dropped to the ground defeated a thought dawned on me.  “That information is in the registry”

Sure sure, but Powershell doesn’t exactly have a “GET-REMOTEREGISTRY” function but it DOES have a fantastically large community of support.   One of the most brilliant Fore Fathers of Powershell is “/\/\o\/\/” or Marc van Orsouw who wrote a blog post explaining how to modify Remote Registry keys in Powershell.

This single post showed how leveraging [Microsoft.Win32.Registrykey] could be used to access remote registries easily!

With this in mind I sat down and played.   I knew that the Registry keeps the data for “Add/Remove Programs” under


So assuming we’re just going to ask a single computer some information, we have to open the main key we’re going to work on







What have we done?

  • Opened the Registry on “local”, accessed the root key “LocalMachine” (HKEY_LOCAL_MACHINE)
  • Opened up a key to view “Software\Microsoft\Windows\CurrentVersion\Uninstall\”
  • Obtained a listing of keys under the “Uninstall” key

That’s it.  So now we have a complete listing (or directory if you like) of all the keys under the Uninstall.

Now that we have the list, we need to pull out the value from the “DisplayName” under each key

To do this, we need to step through the $Subkeys and re-open each key to examine it’s value.  Since each SubKey is just a name, we can just tack on it’s name to $Subbranch and re-open it again.

Once opened, we simply pull out the Value of “DisplayName” using the available GetValule() method.

How did I figure any of this out?

One of the tricks with Powershell is using GET-MEMBER to show you what IS Available for Properties and Methods.   Another I find that really helps is within your Editor (I use The Powershell ISE since it’s convenient and I’m pretty lazy) and putting breaks in the code.

I’ll make that into a different posting later on :)

For now, here is a script you can use to expand or play with to list all the installed applications on a Remote Computer

Remember, the Power of Shell is in YOU

”The Energized Tech”



# Original posting on how to access a remote Registry from The Powershell Guy
# This script will Query the Uninstall Key on a computer specified in $computername and list the applications installed there
# $Branch contains the branch of the registry being accessed
#  '

# format of Computerlist.csv
# Line 1 - NameOfComputer
# Line 2 etcetc etc etc etc An Actual name of a computer

$COMPUTERS=IMPORT-CSV C:\Powershell\Computerlist.csv


# Branch of the Registry

# Main Sub Branch you need to open


# Drill through each key from the list and pull out the value of
# “DisplayName” – Write to the Host console the name of the computer
# with the application beside it

Foreach ($key in $subkeys)
    WRITE-HOST $computername, $Value


# Note – With very little modification (by killing the loop) you could modify
# this script to query a remote machine for a SPECIFIC application


Right around the corner near a major Canadian City near you is Microsoft Techdays Canada 2010

And unbelievable chance to improve your skills exponentially.    It’s a true recipe for success!  Wondering what’s in the mix?

Let’s check out the recipe for this delicious delight!

  • 2 Days
  • 6 Tracks
  • 8 Cities
  • 55+ Sessions
  • 1 Batch of Community Support
  • Three Dozen Plus Session Leads
  • 10,000 Kilos of Speakers
  • 1 Dedicated Team from Microsoft
  • 1 Dash of Inspiration

Take Microsoft Team, sprinkle on a little Inspiration.  Blend in some research from the Community along with support from Session leads and volunteer speakers.   

Mix batch up and bake for approximately six months with some spice across the country.  

When thoughts meld together from Community, Session Leads and Microsoft Team let cool and begin to slice up into Sessions.   

Organize sessions into six uniquely crafted tracks.   Spread tracks across the 8 cities and pull together Speakers and Session Leads as well as additional Community Specialists for Local flavour.

Ensure each track and session has a little coating of each city and send out to the Country cut into days each.

Mmmmmm…… Sounds like a recipe for success to me!  An invaluable treat to be had too!  The price can’t be beat either.  Early bird registration is $349.99 if you hurry!  Vancouver is right around the corner, with Edmonton and Toronto following soon after!

It’s make a GREAT early gift for yourself for the Holiday season too!  Step up to that next level.   Get ahead of the competition!

Dive in and Enjoy a healthy serving of Microsoft Techdays Canada.  

Your mind will thank you for it. :)

The Energized Tech – I’ll see YOU at Techdays!



One of the greatest features that was added to Windows 7 was the Troubleshooting Packs.   Components that can be built and customized to aid in local and remote troubleshooting of issues within the O/S and applications (Including 3rd party solutions!)

Even cooler than that was when I heard Powershell was involved in it!

So quickly I dived online to find out from Technet on how to build one.  After all, in my head, “It’s just a Powershell script”

…. and then my mouth opened up and hit the ground with a thud when I glanced at this article on MSDN on how to create one.   It seemed unbelievably difficult to impossible to create!

But with all problems you take it one step at a time.   To solve this problem I was going to need some goodies

  • Windows 7 SDK
  • Visual Studio 2010 Express (C#)
  • Powershell
  • Time

Well time I had and Powershell is built into Windows 7.  So therefore I was halfway there.

Visual Studio 2010 Express is a free download from Microsoft so THAT part wasn’t so bad.  I quickly began that while I looked into the beast.  The Windows 7 SDK comes in two forms.   A customizable Web Download allowing you to download only what you need or if you want to be a big badass developer guy, you CAN download it as a Single ISO file to burn and share with your other Developer friends. :)

Personally I just want ENOUGH to make the Troubleshooting pack.   Development is cool but it’s not my Forte, so I just want the piece of the SDK that’s needed for Troubleshooting packs.   Sure my hard drive could hold the whole thing, but I like to keep things simple whenever possible.

When I return, we’ll see just what bits ARE required from the Windows 7 SDK and we’ll start down the path of actually building a Troubleshooting Pack.   For you ITPros out there, remember I’m not a Dev either.  So we’ll see just how difficulty this really isn’t. 

The Power of Shell is in YOU
”The Energized Tech”


One of the important things we have to remember when Administering our Networks is a little Segregation.  Separation of our Administrative selves and Personal selves.

Yes as an Administrator you require rights to do your job.   I completely understand and accept this.  I do this daily.

But it’s just as important to make sure you only use the network ID that HAS those rights when you need it.  Whether you have an actual Domain account with those rights or you use good old fashioned “Administrator”

In Windows 7 and Vista this is incredibly easy.  Make your own user a NON Administrator.

Now before you grab out pitchforks and form a mob to have me hanged as a witch, remember this is about security.   Does your user ID (Your PERSONAL ID) need to be running as a Domain Admin? 

No absolutely no.  You NEED those rights when working on users and administering machines.  You DON’T need those rights to run Microsoft Word or the Corporate applications.  If you do, then you should mitigate that issue with the Application Compatibility Toolkit.

So with Powershell we can easily Administer a network WITHOUT our personal credentials being Domain Administrators or Enterprise Administrators.   In fact it doesn’t even have to change our scripts or workflow.

In Vista and Windows 7 all you need to do is check off a little box

Go into the Properties of your Friendly Neighbourhood Powershell Shortcut and find the “Shortcut” tab


Click on the “Advanced” Button and you’ll see an option to “Run as Administrator”, check that box off then click “OK”


Now the fun (and scary part for some Administrators) – REMOVE YOUR USER ID FROM THE LOCAL ADMINISTRATORS GROUP and any Domain Admin groups!

You can take the paper bag off your head.   This is ok to do.

It’s ok as long as you DO have another ID that can be a Domain Administrator (Like Administrator) or possibly create an Administrative account (always a good idea) that has rights matching what you need.

What will happen now is whenever you go to launch Powershell for Administrative purposes is you will get prompted for an ID that has Administrative rights.   The new Shell will launch will all the rights you need to do Domain Administration.

Another option to remember when coding your scripts is you can leveraging the need for credentials in your scripts VERY easily.  Most Powershell CmdLets have the –credential parameter which is incredibly easy to leverage

You can use a sequence as simple as this



GET-WMIOBJECT WIN32_BIOS –computername TEST –credential $CREDS


This will popup a secure box asking for the password to the “CONTOSO\Username” account.  those Credentials in the example above will be passed to the “GET-WMIOBJECT” Cmdlet allowing it to be used to authenticate to the Computer called “TEST”

The neat part, this is not “Theory”.  This is how I do my job daily.   Securely.  Safely. 

You of course will have to ensure your modules are ported over to that user ID or possibly (what I do) is move them to a common profile.


Administration with Powershell – Both Safe and SECURE

The Power of Shell is in YOU
The Energized Tech

Some of you watching the blog will noticed as of late, my posts have been quiet.

Since April 1st 2010, a magic day happened and life got really busy (in a good way), but also things happened at work that made it busy, things happened at home and my eyeballs began taking on this bizarre shade of Purple with Green Polka Dots.

Yes.  Life got a hold of me.   It get’s a hold of us all.   But I seem to have a built in “Anti Burnout” mechanism.  I stop doing things at one point that push me over the edge.

We all have to.  Being an IT Pro or Developer (or almost any job in the IT Industry) can be one of the most passionately time consuming enjoyable and TIME KILLING careers of all time.

I’m not complaining, not at all.  I get to meet new an interesting people as an MVP, get to help out with the big events (sometimes even go to some really cool events).   As an ITPro I deal with some of the most challenging situations presented to myself, not just technological but political.  Of course we have life’s normal little things added into it.

The problem is sometimes we get carried away and those 8 hour days at work become 17 hour days between Work, Community, Commuting, Friends and Family.

…and then you forget about “YOU”.  You can’t forget about yourself.  You have to take some time and literally “Stop and Smell the Roses” or “Sit down with a Book” or just “Play Bejeweled for 27 hours nonstop”

Whatever it takes.   You need to relax, take it easy.  The world WILL still rotate with you not patching workstations or resetting passwords for an hour.

Here’s a few things I have learned …. the hard way.

  • When you’re on a vacation, no matter how important you think work is, SHUT THE DAMN CELL PHONE OFF
  • If you have a choice between getting ahead at work or maybe just taking that weekend? TAKE THE WEEKEND.
  • Birthdays are once in a lifetime, so are Anniversaries and Holidays.  Spend them with those that matter.
  • Forget about posting to the Blog once in a while (or longer).  Sometimes Quality is Better than Quanitity.  Don’t worry.  It will still be there when you get back.
  • Take a day off for yourself, from your wife and loved ones.   Just to stop and think and collect your thoughts.  Come home with Ice Cream. “Just cuz”
  • Sleep in once in a while.  Better yet (if you can) check into a Hotel with your Wife, Partner or Signifigant other just to have a night to yourselves.
  • Stop worrying about losing weight and staying fit for one day and go to a Ribfest.  REALLY!
  • Do something you want to do at work.  Even if it’s just to clean up something that’s been bugging you, like your desk.
  • Watch a Movie! Clean up the wires behind your TV set.  Sit out in the Backyard.   Watch a comedy tape.  Sing. Dance.   Juggle Jello.

Most importantly, remember you are human, not a machine and give yourself a break.   Or that well oiled caffeinated Superman may just burn out.

…That machine is priceless and can never be replaced.  Take care of it.

The Energized Tech
”Enjoying a long weekend” :)