Category Archives: Powershell

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:



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


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

Happy days,

Powershell to Robocopy files (say, to back up your computer to protect against CryptoWall trojan)

We were having a good time on DBAs@Midnight, when Sean got a weird pop up message that said all his files were encrypted, and he has to pay a large amount of money via Bitcoin to get the encryption key. The show quickly ground to a halt as he, then he and Freddie, then all three of us PLUS the chatroom, looked into what this was, how to stop it, what to do, and so on.

In short: Sean lost just about everything. He lost most of what he has on his computer. He lost all the important files that he’d made sure were copied offsite to OneDrive – CryptoWall encrypted those too. (You might want to wait a few weeks before mentioning it in his presence, seriously.)

The funny thing is, we’re data professionals, and we thought we were reasonably well covered for backup. Okay, OneDrive isn’t perfect/ideal, but we neglected to imagine the scenario that didn’t just affect one computer, or one home network, but also spread to The Cloud of Awesomeness.

It’s not the final solution, but…

You’re going to want to get yourself something like Carbonite Cloud Backup (though I wonder, if you have the constant update turned on, whether this would be an advantage against the CryptoWall encryption…probably ONLY if Carbonite keeps file versions).

AND you’re going to want to do regular (say, monthly or so) backups to an external hard drive. I have my Documents folder, my Dropbox folder, and several folders on the root, and even with Robocopy (it comes with Windows!), I found it a little bit of a pain to copy specific things over. So, Powershell!

This script – RobocopyToDest.txt* – lets you define a source, destination, and exclusions (e.g., “don’t copy over the XYZ folder”) to copy a set of directories. It’s a rough cut, I-just-made-this script, but I rant it and it works beautifully. Take it and adjust to your own needs, and for heaven’s sake back up your files!

 *Save RobocopyToDest.txt with a .PS1 file extension. WordPress doesn’t like saving script files, and I don’t like zipping up tiny text files. 

Read up on this stuff

Session: Introduction to Powershell Cmdlets for DBAs

I’ve given my new Powershell Cmdlets for DBAs session a handful of times now, and just realized I haven’t blogged about it!

Abstract: You’ve been hearing about this newfangled craze, and it’s time to learn exactly why it’s called POWERshell. You’ll want to take notes, or better yet, bring your laptop and start using Powershell immediately. We will get Posh running and then I’ll introduce you to the basic concepts, with examples to make things happen right away. We’ll work on SQL Server with Powershell, and learn some cool techniques. Come see this all-demo, hands-on session!

Comments:  This is totally a beginner session. We start by talking about what Powershell is and why it’s awesome, and get into the most basic of basics:

  • write output to the screen
  • aliases
  • connecting to SQL Server from Powershell
  • getting help
  • playing with cmdlet options
  • write to files
  • piping
  • variables

and on and on.

Enjoy, send me questions and feedback, all that jazz. Happy days!
Jen McCown

Download Minion Reindex FREE at