A Holiday Special: Rusty the Red-Eyed Scripter, Part 1


Summary: Rusty the Red-Eyed Scripter discovers compressing files and working with the Clipboard in PowerShell 5.0.

It’s that time again folks—time for the long awaited holiday tradition on the Hey, Scripting Guys! Blog. Get ready for some horrible music and a fun story involving PowerShell. This is our sixth year running the holiday special, so grab a relaxing beverage of your choice and sit back as we begin the watch the journey of an IT pro who has yet to use PowerShell…

  Note   This is a five-part series that includes the following posts:

Let me tell you a tale of a good friend I knew. His name was Rusty. He was known by many as “Rusty the Red-Eyed Scripter.”

Rusty used to spend all day working in IT. Long hours, no rest. He only knew how to automate with PowerShell 1.0, and he had no recent time to learn more. Not a bit. Thus the nickname “Red-Eyed Rusty.” Our good friend Rusty didn’t get much sleep—being an IT pro who spent a lot of time reading on MSDN.

Rusty was smart with technology, but with his long days and minimal time to learn, his only gaps were spent driving his beat up old Geo Tracker between sites and eating lunch from a drive thru.

Yes, we are most definitely dealing with a busy field tech.

One day Rusty heard of some free training at Microsoft called “PowerShell Saturday” in a nearby city. Rusty figured he could use a break, “…and they’re offering free pizza. I wouldn’t mind a slice,” he thought.

So he registered online to grab a spot. Free pizza and free training. Call it an early holiday gift for Rusty. The poor fellow had not had a vacation in six years.

Saturday came along and found Rusty passing across the threshold to a world he only dreamed about. Peering down the halls, he could see people happily bustling about, “It must be wonderful to work here,” he thought.

Rusty was nervous, having never been to Microsoft before. He sat near the back as a fellow with a green tilley outback hat opened the meeting. “Welcome everyone. My name is Rick and I work on the DX team here at Microsoft. I’d love to tell you about all the new hardware I get to play with, but I broke it all last week. So I spin up machines in Azure which is far cheaper for Microsoft”

That joke got a good laugh from the crowd and it made Rusty feel at ease knowing that nobody in this world was perfect. Rusty got comfortable as Rick began introducing everybody to a new technology called Windows PowerShell 5.0. He was comfortable with version 1, but was afraid to even look at all the new features in version 5. After four versions, almost everything he knew must be too different.

A young fellow noted the discomforted look on Rusty’s face. He looked over and offered his hand. “Hi, I’m Thomas. I flew in from Edmonton. Don’t worry. Rick doesn’t bite…often.”

The joke made poor tired Rusty smile. “I’ve never had the time to learn about much PowerShell except for some bits in PowerShell 1.0. In my job I’m a field technician. I’ve heard it’s easy, but I could never learn scripts or scripting. I’m not sure how useful this will be for me.”

Thomas sat down with Rusty for a moment during the coffee break to show him some things he loved about PowerShell 5. “I always thought PowerShell was cool, but I’ve been quite busy myself and just recently looked at version 5. You know what I thought was the coolest part? I didn’t have to “unlearn” anything to use it. They just made things far better.”

Rusty nodded. “I always wished PowerShell could make archives for me. I ended up downloading some older DOS software, or in some cases went to the GUI and used “Send to Zip.”

Thomas piped up, “Then you’re going to love this feature. We can now compress and uncompress Zip archives with PowerShell by using two new cmdlets. Check this out. To compress a folder called C:\ScriptingGuys, I can do this!”

Thomas opened his PowerShell 5 console to demonstrate, and he typed:

Image of command

“Then I can reverse the process with the Expand-Archive cmdlet like this!”

Image of command

“Oh!” Rusty’s eye’s popped open like a jack-in-the-box. “That’s pretty nifty! Hey, I just realized something. This is far easier on the eyes than PowerShell 1. There seems to be a whole lot of color on the screen.”

Thomas nodded. “That’s the new PSReadLine module that’s loaded in the back end. It not only makes PowerShell visually nicer, it gives us new features. I can actually type on the screen and paste the code directly elsewhere.”

Rusty remembered going to the console prior to this and choosing Mark/Copy to get information on the screen. Seeing how he could hit CTRL-V to put information directly into the console was pretty cool.

Thomas looked over. “But it’s so much more than this. With PowerShell 5, I can use two incredibly powerful cmdlets called Get-Clipboard and Set-Clipboard. It’s beyond copying text—I can copy file structures in PowerShell 5. I can grab a list of files like this:”

Get-Childitem C:\Foo\* -file

“…then copy those to the clipboard by using Set-Clipboard.”

Get-Childitem C:\Foo\* -file | Set-Clipboard

“If I’d like to review that content, I can look at it with Get-Clipboard and target the format as FileDropList.”

Get-Clipboard –format FileDropList

Image of command output

“Or I can go straight to a folder in Windows Explorer and use a CTRL-V. But the best part,” continued Thomas, “is the built-in history feature in PowerShell 5. It remembers a history of everything I’ve done. I can now scroll back and forth by using the Up and Down arrow keys.”

Rusty’s eyes opened wide at this point. He immediately saw a simple case of how PowerShell 5 was merging the world of the console and the GUI and how much easier it was to use.

They returned from the coffee break to watch more of the presentation. PowerShell 5 had lit up Rusty’s eyes a bit—a hint of the red beginning to die away.

Stick around for tomorrow as we continue into more of Rusty the Red-Eyed Scripter’s journey through the land of Windows PowerShell 5.0.

I invite you to follow the Scripting Guys on Twitter and Facebook. If you have any questions, send email to them at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, always remember that with great PowerShell comes great responsibility.

Sean Kearney, Honorary Scripting Guy, Cloud and Datacenter Management MVP 

Comments (0)

Skip to main content