Powershell

Some days with Powershell we’re productive, some days we have fun.  Some days we mix in a little of both.

Today we’re going to see what fun we can have with the ComObject “Shell.Application”.  This single Com.Object is your entryway to almost everything tied to Windows Explorer.

Well maybe not absolutely everything but a lot of fun and maybe not so productive things.

We’ll create a link to the ComObject in the normal fashion

$EXPLORER=NEW-OBJECT –Comobject “Shell.Application”

Once complete we run a GET-MEMBER against it to see what’s inside Pandora’s box.

image

… After picking yourself up from the floor from that woozy fainting spell you’ll see there is actually quite a bit you can do with this.   Let’s try a little one.

$EXPLORER.Explore(“C:”)

With any luck, you’ll now be staring at a window opened up on your screen showing you the “C:” drive initiated from Windows Explorer.  Next try a

$EXPLORER.Minimizeall()

Yes, sure enough, all the Windows are now minimized. (Including your Powershell Console!)

$EXPLORER.UndoMinimizeAll()

Trying this

$EXPLORER.WindowSwitcher()

Now you’re seeing the Windows Task Switcher, or if you’re running an Aero Desktop, Aero Flip.

$EXPLORER.CascadeWindows()

The point of this post is two things.  One; Have a little fun with Powershell and Two for you to discover how easy it is to play with ComObjects and discover their abilities within.   Run a Little GET-MEMBER on your results and you’ll be surprised how far down the rabbit hole goes.

The Power of Shell is in YOU

Sean
The Energized Tech