PowerShell for fun (and profit?)

PowerShell is useful for a great many things, but I like it best (on a day-to-day basis) for the little things that it simplifies. For example:

  1. Windows-R to get a Run dialogue.
  2. Type powershell.exe restart-computer
  3. And your computer restarts!

I like this a good deal better than all the hunting around with a mouse to find the durn power icon, wherever they’ve moved it THIS week.

I also dig being in a PowerShell window and being able to open the output file I just generated, with the command notepad.exe c:\temp\filename.txt.  I am nothing if not lazy efficient.

What other fripperies can we use in PowerShell?

So I got to thinking…PowerShell must know where Notepad.exe is – namely, in c:\windows\system32. So it must (of course)  be able to run other system EXEs really easily.

I began scrolling through the extensive list of apps in the sys32 folder, and stumbled across:

cmd

*snortlaugh*

Sure enough, you can “launch” the command window from within PowerShell. It looks a little like this:

poshcmd

Yes, this is silly, and mostly useless. But it’s fun. Or more to the point, funny.

Okay but seriously, why are we talking about this?

Mostly because it amused me. But also to remind you that there’s good work to be simplified with PowerShell, and sometimes some good fun to be had, too.

You can, for example:

  • Launch the control panel with control.exe
  • Or MS Paint, mspaint.exe (I’m not the only one that still uses this!)
  • Or Magnify, magnify.exe

If you’d like to learn PowerShell, check out the Beginning PowerShell session on our Events page, and the PowerShell tutorials on MidnightDBA.com.

Happy days,
Jen

3 thoughts on “PowerShell for fun (and profit?)”

  1. PoSH is indeed great fun. Instead of starting notepad and open a file try this: ii c:\temp\filename.txt It will perform the default action associated for the extension.
    ii is short for invoke-item. Using these short aliases is maybe not best practice, but it makes your code looks like magic :)

Leave a Reply

Your email address will not be published. Required fields are marked *