For He’s A Jolly Good Fellow

Snover-PowerShell-NukeBy now I’m assuming most of you have seen or heard the news that Jeffrey Snover has been promoted for the last time and is now a Technical Fellow at Microsoft. I want to add my congratulations and adulation to the thundering masses of PowerShell professionals. I always thought his previous position as a Distinguished Engineer was an amazing distinction but his new title opens up an entire new chapter in his life and most likely ours. Becoming a Technical Fellow puts Jeffrey Snover on par with icons such as Dave Cutler and Mark Russinovich. But what does this mean to you?

Well, the first thing I would say is that this is the ultimate validation of PowerShell’s place in Microsoft’s vision. Snover has been running all things Windows Server for a while now and still keeping his hand in the PowerShell world. So if you were one of those people (and I can’t believe they still exist) that PowerShell isn’t important, this is the last memo you’re going to get. If you are not using and learning PowerShell today, I don’t know how you will do your job tomorrow. Or perhaps more accurately that your career path will be limited.

Brilliant minds like Jeffrey Snover dropped a bomb on us almost 10 years ago and we’re still riding the shockwaves today. But instead of wanton destruction he, along with plenty of other brilliant minds on the PowerShell and Server teams, have created a landscape of opportunity and innovation. For that, thank you Jeffrey Snover and congratulations on a well-earned recognition.

What Were You Working On?

toolboxIt probably comes as no surprise that I write a lot of PowerShell code. Like you, I’m usually working on several projects at the same time, most often using the PowerShell ISE. When I fire up the PowerShell ISE I often go to most recently edited files and re-open the files I was last working on. But sometimes my list of current projects gets pushed aside by other files I might open and edit. Because I like to be lazy (I mean efficient) I decided to come up with a solution to make it easy to open files I’m actively developing.

In the PowerShell ISE you can easily load a file into the editor with the PSEDIT command.

So all I need is a way to store my active files. It is simple enough to use a text file. All the text file needs is a list of full file paths. Opening all the files can be as easy as this:

But how can I easily add a file to the list? I can use the PSISE object model to get the path for the currently active script file and add it to the file.

To remove a file from the list, it is probably easiest to simply open the current work list using PSEDIT and manually delete what I no longer need. I took these core commands and wrapped them in a set of functions. And of course, I don’t want to have to type any more than I have to so it would be handy to add some shortcuts to the ISE Add-On menu.

I ended up creating a set of functions for these key operations and incorporated them into my ISE Scripting Geek module. The module exports a global variable for my work list.

Now when I open the ISE I can press Ctrl+Alt+I and have immediate access to everything I’m currently working on. This has already saved me a lot of time and frustration.

I have moved the ISE Scripting Geek module to GitHub so check it out here. Feel free to pick and choose what you want from the module or take my commands here and create your own solution for loading your active work files. The functions for this particular feature are in CurrentProjects.ps1.

Enjoy and let me know if this starts saving you some time.

Updated PowerShell Formatting Functions

Last year I posted an article and a set of PowerShell functions to make it easier to format values. For some reason, I decided to revisit the functions and ended up revising and extending them. I modified Format-Value so that you can format a number as a currency or a number.


Format-Value help (Image Credit: Jeff Hicks)

The function is assuming you will pipe values to it.


Format-Value examples (Image Credit: Jeff Hicks)

I also wrote a new function called Format-String.


Format-String help (Image Credit: Jeff Hicks)

The nice thing is that you can apply as many or all of the formatting transformations as you want.


Format-String examples (Image Credit: Jeff Hicks)

The Replace option works by taking a hashtable and replacing each matching key with its value.


Using the Replace parameter in Format-String (Image Credit: Jeff Hicks)

One task that comes to mind where Format-String might come in handy is in building passwords.

The function contains the following aliases:

  • fp = Format-Percent
  • fv = Format-Value
  • fs = Format-String

I’m also trying something different, at least for me. Instead of posting the code here, I’ve started to use GitHub since that seems to be what all the cool kids are doing. You can find the FormatFunctions module at https://github.com/jdhitsolutions/FormatFunctions. This should also make it easier for me to post revisions, address bugs and make it easier for you to take my code and run with it. You’re still welcome to post comments here, but use GitHub for anything specific to the PowerShell code.

Enjoy.

 

Advice, solutions, tips and more for the lonely Windows administrator with too much to do and not enough time.