December 2010 Archives


To save you all some searching.  Here are the links to all SEVEN parts of “A Powershell Carol” on “Hey Scripting Guy”

Just cuz Smile

Weekend Scripter- Holiday PowerShell Carol, Part One
A PowerShell Carol in which Ebenezer Script Learns WMI
A Windows PowerShell Carol- Ebenezer Script Integrates with VBScript
A Windows PowerShell Carol- Ebenezer Script Manages AD Users
A Windows PowerShell Carol- Ebenezer Script Creates Text Files
A Windows PowerShell Carol- Ebenezer Script Sees the Future
Weekend Scripter- A Windows PowerShell Carol- Ebenezer Script Learns to Send Email

And if you have no time to read the Complete Podcasted version is available on my new Podcast site

I highly recommend reading the ones on “Hey Scripting Guy” first as they actually do show you some basics on Powershell and more importantly help you to quickly understand how it does work easily with vbScript.  If you’re an Administrator floating between both worlds; knowing how to leverage these two technologies seamlessly is an unbelievable power.

Surprisingly also very easy

Happy Holidays from The Energized Tech


At long last, we shall finally see what happened to Ebenezer Script on “Hey Scripting Guy”.   For the final installation of the series is online now.

Did he learn from his mistakes or is he doomed forever to his miserable ways and the past?

Only you can tell by going online now and reading A Powershell Carol – Part 7 on Hey Scripting Guy

Now a double bonus for those of you who would like to hear the Podcast version

Two links… YES TWO! The Holidays are here and you can now hear

Episode 6


Episode 7

or if you’d like to download the entire series just go to

If you didn’t see it before, That little video of the “Mr. Script” song

And now a personal message.   A thank you to the ENTIRE Windows Powershell Community (and Especially Ed Wilson of “Hey Scripting Guy”) without whom none of this would have ever happened.   An extra special thanks to my wife and family for putting up with the singing, the howling, early 5 am recordings and the owners of the oranges and Volkswagen some kids knocked over.

Happy Holidays from The Energized Tech, Bob Snipit, Jacob Clippy, Tiny Shim, The three Spirits and of course…. Good old Ebenezer Script!

May the Spirit of Scripting stay in YOU

A Powershell Carol–Part 6

| | TrackBacks (0)


Tension in the Air!  The Future is roaming about!  And the final of two episodes is online right now at “Hey Scripting Guy”

The Spirit of Scripting Future is in the house, and his one BadAss ….  He’s a tough guy.

All I have for Ebenezer Script is one phrase he should fear…

….Would you Like Fries with that?….

By the way the Podcast version of Yesterdays episode (Part 5 for those of you counting) is online now

Happy Holidays and Keep the Spirit of Scripting in YOU

The Energized Tech


Ebenezer Script will receive a “Present” today. 

Was that a bad enough pun for the Holidays?

Never mind about my horrid jokes.  It’s here!  The Fifth Episode of “A Powershell Carol” is online at “Hey Scripting Guy” Hurry up and don’t miss a bit

Want  to hear some horrible acting?

The Podcast version of Yesterdays’ episode is sitting right here for you

Cheers, Happy Holidays!

The Energized Tech


Last time we discovered just how powerful yet SAFE Powershell is with the –WHATIF parameter.  Today we’re going to show you how navigating the Registry is very similar to navigating and working with the filesystem with GET-CHILDITEM and GET-ITEM

So in Powershell we have what are known as “Providers”.  Providers (for lack of better words) “Provide” us with a neutral method to connect to various unrelated systems.

To get a list of Providers I just key in


This will give us a list like this


As you can see there are various providers in Powershell.  Some for WebServices Management, File system (C,D) and even certificates .  

So to get a directory in Powershell I normally key in something like


Here’s the cool part.  Do you see under “Drives” we have two entries ?  HKLM and HKCU ? If I would like a like a Registry keys in HKLM (HKEY_LOCAL_MACHINE) I would just key in



As you can see, we’re looking at a list of registry keys.   As you can ALSO see, Powershell has to work with the same ACL’s as in the real world so if you try to access something YOU’RE NOT EVER SUPPOSED TO TOUCH (like our little friend “SAM” here) it will spit out an error.    But for neatness, we can tell Powershell to suppress those errors too.     Although you can change the overall configuration by messing with your variables,  I like to do it on an as needed basis.  Adding on the parameter –ErrorAction SilentlyContinue allows this to not disturb you temporarily.

GET-CHILDITEM HKLM: –ErrorAction SilentlyContinue


If you’d like to set this as a default in your profile or even just even  for all the Cmdlets in a session just set the Variable $ErrorActionPreference=’SilentlyContinue’

Now here’s something you just couldn’t do in DOS.  Change from the File system to the Registry just as if it were a Drive letter!

Key In


and then type in


then execute a GET-CHILDITEM


Does this look familiar?


You guessed it.  With Powershell you can not only VIEW but Navigate the registry as easily as the filesystem.

Next time we’ll take a glance at creating content in the registry with Powershell

The Power of Shell is in YOU

The Energized Tech

A Powershell Carol-Part 4

| | TrackBacks (0)


Hark!  What do I hear in the air? More Spirits?  The Drama unfolding further?

“A Powershell Carol” continues online on “Hey Scripting Guy”

Hurry up! and Look out for giant 50’ Floppy drives!

The Special Podcast version of Episode 3 is now available online here too!

The Spirit of Scripting is in the Air!

The Energized Tech


The drama ripples through the air as the Third episode is released on “Hey Scripting Guy” of “A Powershell Carol”

Will Clippy drive us all nuts?

Will Ebenezer forget how to spell vbScript?

Will the writer finally get to the point and say something?

the only way you’ll find out is if YOU go to the site now and read the story!

But don’t forget!  The special podcast version of yesterdays episode is right here

Happy Holidays

The Energized Tech


So last time we saw with Powershell it was very easy to pull down files based upon Date and Time.  That he had far more power to query the filesystem as if it were a database.  Which in a sense it is.

But what is one of the more common operations we do on our file system ?  We clean up old data.  We delete garbage that is just that (trash) cluttering up the file system (like temporary files).  Sometimes we move older data somewhere else.

But the problem we’ve always had to deal with was if we wrote a query in DOS or vbScript, well it was a bit scary.  You would have to create a test structure REALLY if you were doing anything complex to avoid “Murphy”

But Powershell changed the scope with one simple parameter


-WHATIF” does exactly what you think it would do.  “What IF” I did this?  What would “IT” do?   This parameter gives you the ability to test a “Destructive Cmdlet” on live data without actually hurting it.  When run it gives you a line by line view of what it was GOING to do IF you allowed it to run through

This parameter is used in Multiple Cmdlets that do things that are usually pretty difficult to roll back (like deleting objects in Active Directory, Removing Files / folders or chopping off Branches in the Registry Tree)

So let’s take a look at an example.  If we took a directory of objects in the file system with GET-CHILDITEM

GET-CHILDITEM C:\Powershell\*

Which shows us a list of files in the C:\Powershell\ Folder.  Now all we need to do to remove anything in that list of Objects is pipe it through REMOVE-ITEM.  But really, safety first so we’re going to add on the “-WHATIF” parameter


Running this command will give us this type of an output


But running a GET-CHILDITEM on that same folder will confirm all is there still.  This is one of the simplest and best features in Powershell.   “-WHATIF” let’s you do something, (and if you’re not sure) not hurt ANYTHING in the process.

So if your INTENTION was to only remove those old text files and NOT your entire folder, you were still safe.   You could just as easily query Files by type, date / time, recurse into folder trees and STILL use “-WHATIF”

Next time we’ll see just how easy it is to navigate the registry in Powershell.

The Power of Shell is in YOU

The Energized Tech


And the series continues! Quickly go online to “Hey Scripting Guy” and find out just what old Ebenezer Script is up to

The tension

The drama

The overacting

W-M-I !

So hurry and run over to "Hey Scripting Guy" on Technet to see what’s going on with a “A Powershell Carol”

But if that wasn’t enough?  The special Podcast version of yesterdays’ Episode is right here! That’s right!

Stay tuned for tomorrow for further updates and the NEXT Podcasted episode

Happy Holidays !

The Energized Tech



… And so it begins … a Powershell Carol.  The first episode is now OFFICIALLY online at Microsoft on “Hey Scripting Guy – A Powershell Carol – Pt1” 

It appears the special Podcast version hyperlink did not make it to posting.   But just wait ‘til tomorrow!  I’ll post the Hyperlink to the “Once in a lifetime Podcast version” of a Powershell each day AFTER the original post goes online Smile

Happy Holidays everyone! 

The Energized Tech

Listen to this Radio announcer!  A NINE days Holiday Special from Dec 18th all the way until Dec 26th !

This is the real deal!  Don’t miss out all 9 days on "Hey Scripting Guy"


TechNet Webcast: Windows PowerShell Basics for IT Professionals (Part 2) (Level 200)

TechNet Webcast: Windows PowerShell Basics for IT Professionals (Part 2) (Level 200)

Event ID: 1032473252


Product(s): Windows Server 2008 R2.

Audience(s): IT Decision Maker, IT Generalist.

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.  
Special offer for live attendees of this webcast: Are there admin tasks you would like to automate, but you are not sure how? Do you want to learn Windows Powershell, but you don't know where to start? 
Send us your scenarios at byWednesday, January 12, 2011,  and then join us for the webcast where we show how to use Windows Powershell to make your life easier.

Sean Kearney, Network Administrator, Microsoft MVP, MCSE, MCTS,
View other sessions from Windows Server 2008: Web, Virtualization, Security, and a Solid Foundation
If you have questions or feedback, contact us.


If you haven’t heard, set your browser to point to the “Hey Scripting Guy” blog from December 19th to December 25th for “A Powershell Carol”

A little twist on Charles Dicken’s “A Christmas Carol” that is  a week long series about a grumpy miserable Administrator called Ebenezer Script.   We all know somebody like him.  Sometimes inside of ourselves on our worst days.   Snapping and lost in his ways.

With a daily downloadable version of the posting with lots of horrible acting but and “Energized” but definitely uncredited voice actor and Complete with a Theme Song that can be downloaded now (Parody folks, PARODY, source music can be purchased from Winking smile )

Hoping to make your Holidays a little brighter.  You might even learn just a little about Powershell.  Even if you don’t care about Powershell or Scripting, read it and enjoy.   There’s enough content any computer person should be able to share in it.

Cheers and set YOUR browser to HTTP://BLOGS.TECHNET.COM/HEYSCRIPTINGGUY from December 19th all the way until December 25th.  That’s right!  One Episode each day until Christmas Day, with the Final Episode released to you as a present ON Christmas Day.

A little from Myself and “Hey Scripting Guy” to you Smile

Happy Holidays
The Energized Tech

Few of us praise those we work worth, few of us praise our employers.  Today I must stand back, take my hat and bow to my employer.

A large praise to Mine

Few of you know my employer.  Mine makes a difference daily to those in peoples day to day lives, there are many on the front lines and I will try to pass along as much praise as are people.

Even fewer of you know what goes on behind the scenes.  I will keep names quiet but I will state teams and praise.

For those gentleman and ladies who quietly man the Help Desk.  Cheers.  You listen to everything every whining, bitching, irritating, complaint.  You solve it without complaint (or at least any that anybody gets to hear about)

To the Network team, those quiet people who magically reprogram details in the background, monitoring obscure abnormalities and often catch that odd “wiggly wire”

To those Infrastructure people, the ones that find the balance between what Executives want and what is needed.

To those that handle the phones daily. quietly missed; saving lives every minute of the day

To Managers; those who feel the spite of staff while still forging that balance with the customer.

To the VP’s who feel the wrath of daemons when all breaks loose, yet no matter the issue; you show the face of angels.

To the Developers of various topologies who forge the most creative solutions in the most unforgiving of environments.

To you, and the many others I may have forgotten (for so many fight the good fight daily) I raise a toast.

You are my co-workers

You are my friends.

… and for you I must raise a toast for helping me daily, for putting up with my weakness, my failings in my efforts.   For we are a team.

Today we will make a difference.  

To all of you, no matter where you work.   Remember.  You do have friends.   Do not forget them, no matter how bad the day.  They will not forget you

…… and occasionally….. buy the Boss lunch.  They have bad days too Winking smile

A little something to share with the rest of you

I was writing the series “A Powershell Carol” (online at from Dec 19th until Dec 25th) and I kept humming the “Mr. Grinch” song

Let’s just say, I got a little carries away and you now have a Goofy song and video you can share with your friends and neighbours

I give to you

“The Mr. Script Song” – Happy Holidays !

Ok… Had this one and I have to share.   We had two Virtual Machines that just for LOVE or MONEY wouldn’t take take Hyper-V Integration Services. 

The machines were originally created in Virtual PC, VM Additions were removed.  But the only way they would work was with a “Legacy Network Adapter”

Today I had to migrate them to our Highly Available system and wanted this fixed, ONCE and for all!

I removed the services.  I reinstalled them.  I shutdown the system and did “Install Guest Services”

Do you think that worked? Nope.  But I checked online and it turns out the answer is very simple.  These machines came from Virtual PC 2007 which shows up as a different HAL.   The fix was a checkbox.

Run MSCONFIG and just check off the “Boot” Tab


Click on the “Advanced options” button


And then just simply click off the box that says that says “Detect HAL”

Click OK, then “Apply” then OK one more time.  Reboot when prompted

Upon reboot, the  “VMbus” in Device Manager will clear away and be replaced by all the stuff you REALLY needed.  Like you Synthetic Network card, Video card…. SPEED and RAW POWER.

See?  No need to panic.  It’s all possible to be solved.  Now go and enjoy a Cookie Smile

The Energized Tech


So we’re now looking at Powershell and realizing it’s a whole lot more than a big funky Blue command prompt.   Even if it just appears that way to make us more comfortable.

So one of the nicest things I ever got out of Powershell (the thing that just HOOKED me in) was the easy way it could work with files and folders.

For example GET-CHILDITEM (when working in the default context of the File system) gives us our familiar Directory and files.

But what we’re REALLY getting is a list of Objects and that list can be accessed item by item, just as if you were going and view rows and columns in an Excel Spreadsheet.

So here, let’s get a directory with some files and folders and store them away for safekeeping.


So if we were to try accessing this information in $LISTOFSTUFF we can just key in


which will dump the whole pile on our screen. Or we can examine it Piece by Piece like this




…… etc etc etc…

But wait! There’s more! I can tell you how much “Stuff” is in $LISTOFSTUFF


But the magic isn’t over.   Have you EVER wanted to find all .TMP files on a file system?  or any other type?

GET-CHILDITEM –recurse –include *.tmp

One line.   and again you could store that away in a variable to work with it more easily

$TEMPORARYJUNK=GET-CHILDITEM –recurse –include *.tmp

But here is where the fun starts.  Do you remember how we can compare dates and times?  How would you like an EASY way to show all files that have been accessed in a certain time range?

With each of the items in the directory there is a field called “LastWriteTime”.  This field has a Date and Time you can use to compare with.  But how does one does this?

Remember Piping?  We can run that list of information into another Cmdlet called “WHERE-OBJECT”.  WHERE-OBJECT has a very simple job and that is to Look at information given to it and filter based upon criteria.

In English? It lets you pull what YOU want out of a list.

To to figure out if a file is a certain “age”, just Subtract the “LastWriteTime” with the “CurrentTime” (GET-DATE)

Why?  Well think about it.  Every file is automatically going to be (well just ABOUT every file) older than that EXACT point in time you did “GET-DATE”.

So you could get the date


and then GET the Directory and files like this

GET-CHILDITEM C:\Scripting | Where-Object { ( $STARTDAY-$_.LastWriteTime).Days() –gt 3 }

Will show you all the files in that folder over 3 days old.

And just as easily you can tell it with one minor change, all the files that were accessed within the past hour

GET-CHILDITEM C:\Scripting | Where-Object { ( $STARTDAY-$_.LastWriteTime).Hours() –lt 1 }

Have I poked at your Curiosity?  Good.  Next time we’ll show you how easy it is (and safe) in Powershell

The Power of Shell is in YOU

the Energized Tech

The title is revealed officially and I’m letting you all in on the secret.  Pass it on to your friends your neighours and family.

Hey, even let the little Gerbil running about in the cage now.

It’s a SEVEN part series EXCLUSIVE to “Hey Scripting Guy” that will start on December 19th 2010 and run all the way and INCLUDING December 25th 2010.

It’s something that "Hey Scripting Guy” (Ed Wilson) came up to me and asked “Would you like to do a little post about Powershell for the Holidays” and it kind of grew from one post to an entire story.

You may also may want to follow some twitter accounts which may chat from time to time each day of the story.  They will be followed with the Hashtag of #powershell and #vbscript when they talk, and won’t be hard to spot

It’s an Epic tale of … well I’ll let your imagination wander on that one.  But anybody who knew me as the “Friday Funny Guy” rest assured I have tempered all my skills towards making this happen in a way that Steve Ballmer, Paul Allen and Bill Gates themselves would be proud to see it on their website.

So set aside a few minutes each day from December 19th til December 25th on “Hey Scripting Guy” to read.   Whether you script or not, you will enjoy it.  I promise. 

Cheers and Happy Holidays

The Energized Tech


So with Powershell from last time, we discovered that through Aliases it is just mimicking older DOS functions to give us a comfort level.   It’s not just a “Big Blue Command prompt”

So what is it?  Let’s try to be grey on that.  You have to be because Powershell is really HUGE when you open it up.  It IS many things to many people.

Calling it “A scripting solution” makes it sound like just a replacement to vbScript.   Calling it a Management Console ignores the scripting abilities.   Calling it a new system makes it sound isolated from the old.

Powershell is whatever YOU need it to be.   I’ll show you where it got me hooked in.   Easily being able to examine File content by date or time.

Here is a solution I personally encountered that showed me the raw Power of Powershell.

I can EASILY work with Dates and Times, and with that I can sort through files by date and time easily.

If I executive this Cmdlet


It just pulls up the Date and Time.  But If I store it away in a Variable called $TODAY


I have that information from that EXACT point in time stored.  Now for the cool stuff.   Powershell has a CmdLet called GET-MEMBER that reveals all the Members of that particular Object.   Placing a “|” between $TODAY and GET-MEMBER “Pipes” the information from $TODAY to GET-MEMBER



There is a list of very interesting Properties sitting here.  For the first time, like me you’ll start to yawn when somebody starts describing Objects.  So we’ll talk about all the fancy bits and pieces later.  The important part is I can look at INDIVIDUAL PIECES of the date easily.

So If I want to access JUST the year from my Date I can type in


or the Hour of the Day


Simple neat, so far useless to the ITPro.  We need to compare dates, Logon Dates, File Dates.  We need to easily know  how old something is.   Well again with Powershell, that easy

Believe it or not, I can just SUBTRACT dates and compare dates, step back and forth in time.


Will display the Results of $TODAY as 5 days in the future.


Will display the Results of $TODAY as 4 months from now.  But $TODAY is still intact

So here is neat thing to try so see how you can compare.  Subtract $TODAY.AddMonths(4) from $TODAY



As you can see it breaks the results down in various details.   I could compare two dates and easily know they are over 121 days apart, because Powershell will show me that.  How do I access that difference?  Here’s an example



And we’re seeing the Days as an actual number.  Can you imagine leveraging this power in YOUR environment? Next time we’ll show you how on the file system.

Remember the Power of Shell is in YOU

The Energized Tech