Essential PowerShell: To alias, or not to alias, that is the question

Recently there was a discussion between community experts and a product team about a module they are working on.  The topic being discussed was cmdlet aliases: whether or not they should provide aliases for their cmdlets out of the box and if so, how they should be provided.  Aliases are great for ad-hoc PowerShell work, which is what most PowerShell users do at this point, and incredibly useful when you’re trying to put out a fire and managing your infrastructure using PowerShell.  However, there are many important things that module authors need to consider when planning aliases for their cmdlets, as follows:

1. There are many cmdlets out now, and more and more every month.  Coming up with a vsa (very short alias) that is unique is a challenge at best, and the more time goes by the more tla’s (three-letter aliases) will get used up.  The likelihood of an alias conflict is already high, and increasing all the time given the number of commands that are available both from Microsoft and from third party vendors.

2. The land grab with alias names is worse than it is with functions or cmdlets.  With functions or cmdlets, you can have multiple modules loaded with conflicting names and access either command using the fully qualified command name.  With aliases though you are not provided this same capability – there can be only one.  Aliases are simply commands set to a single value and they cannot be qualified using a module name qualifier to disambiguate if a name conflict arises.

3. Depending on how careful (or not) that developers are, it is very easy for a module author to completely take over (overwrite) an existing alias with no warning or message indicating that this has happened, resulting in potential command hijacking between module teams.  A simple call to Set-Alias does this without warning.  On the flipside, if developers don’t hijack aliases, then some of the aliases they would otherwise create may simply not be defined.

4. When aliases are hijacked, unloading a module doesn’t correct the problem because an alias that was overwritten by a module alias will simply become completely unavailable when the alias is removed as the module is unloaded.

As far as I am aware, this situation does not improve with the next version of PowerShell either, so it’s years away from getting better.

Believe it or not, even with these things in mind, I’m actually still pro aliases.  I just think that some extra care/thought needs to be put into their definition.  There is no real standard here that both satisfactorily addresses the issues identified above and that allows for consistency across companies/teams at this time.  Given that is the current state of affairs, if you are considering aliases for your module I recommend one of the following approaches:

1. [SAFEST] Rather than trying to come up with something that can be shipped despite these issues, at this time I think aliases would be best addressed in a "tips and tricks" type of blog post, proposing a short script that defines some useful aliases for the module/snapin in question in order to allow admins to be able to deal with fires quickly using ad-hoc PowerShell commands via some aliases.  Such a script should generate warnings whenever a name conflict is discovered so that users are aware when an alias either cannot be created or is overwritten.

2. [EXPERIMENTAL] Ship aliases with your module, but try to make sure they really are unique.  For example, if you’re a vendor whose company name starts with Q, you could prefix all of your aliases with "q".  This is attractive because there are no verbs that start with "q", so right from the start you’ve dramatically reduced the chance that you’ll have a conflict, setting yourselves up better to have aliases that belong to you.  Then you would only have to coordinate within your company to make sure the aliases used across teams are unique.  This isn’t foolproof though because there may be multiple products/vendors that adopt the same standard, and if the name of your company or product starts with G, the likelihood of a conflict would be much higher (the alias prefix used for "get-*" cmdlets is "g") so you may want to choose a pair of letters instead.  Regardless, you’ve likely reduced the risk, and you could generate a warning whenever you run into a conflict that prevents an alias from being created.

3. [RECOMMENDED] Lots of 1 and a little bit of 2: use unique alias names that work for your product team/company, but don’t ship them with the module.  Instead, push them out as a value add on a blog post, and see how the community responds.  At the same time work with MVPs and Microsoft to get these issues addressed such that a shorthand system for command names does work.  Some MVPs, already proposed a few things to the Microsoft PowerShell team that could help here (aliases for module names for one — think PS\gsv for a core PowerShell version of Get-Service or EX\gu for the Get-User cmdlet that comes with the Microsoft Exchange module or AD\gu for the Get-User cmdlet that comes with the Microsoft Active Directory module, and so on), but more discussions need to happen and this will take more time.

I recommend the third option because given the current issues with alias hijacking and with no support for disambiguation, it seems to be the best solution for now (from my perspective at least).  If you have come up with other alternatives that resolve these issues, please share them with the community so that this improves going forward.

Hope this helps,

Kirk out.

PowerShell MVP for 2012

Every year around Christmas I anxiously await the New Year to see if I receive the Microsoft MVP award again that year.  Well that email came on January 1, 2012, and I’m quite thrilled about this one because it’s a milestone this time (year 5 as a PowerShell MVP).  Thanks to the community for being so great to work with, and thanks to Microsoft both for recognizing individual efforts with the MVP program and for creating such great products like Windows PowerShell!  Work has never been so much fun!

Kirk out.

PowerSE 2.5.3 is now available

A little over a week ago we released PowerSE 2.5.3 to the web.  You can download the latest release here.  This release includes many great improvements to the PowerSE product, many of which were requested by you, so thanks for your feedback and please keep it coming!

No time limit for freeware

With this release, we’ve removed the requirement to re-download this product every 60 days.  This was our number one feature request since we made PowerSE a freeware product.  Now when you download PowerSE 2.5.3, it is truly freeware and you can use it as long as you like!

PowerVI Integration

Since PowerVI has joined the Devfarm family of products, we have now improved the integration between PowerVI and PowerSE and PowerWF. This enables easier authoring and testing of VMware automation scripts and workflows before you publish them to be integrated in the vSphere client, and it highlights one of the greatest values of the Devfarm products – the rich integration between them that make everything much easier.

Tabs to spaces support

We’ve added support for configuring how tabs are used in the PowerSE Script Editor.  If you want spaces inserted when you press the Tab key while editing scripts, all you need to do is to set $psise.Settings.AutoConvertTabsToSpaces to $true in the embedded console.  If you want the tab size to be something other than the default value of 4, you simply set $psise.Settings.TabSize to the number of spaces you want to use for tab characters.  These only need to be set once, so you can simply make the calls in the embedded console and then you’ll always have it configured that way going forward.

Enhanced history pane

The history pane in PowerSE has always been useful, but now it’s much better!  With the history pane in PowerSE 2.5.3, you can identify which commands were successful and which were not, all at a glance by looking at the icon.  You can also tell which commands were allowed to run to completion and which were cancelled.  Most importantly, you can identify the duration of any command that you run, so if you are trying to get the most performance from your scripts, this is an easy way to compare the performance for several related commands so that your scripts run as fast as they can.

Greatly improved support for international environments

In previous releases of PowerSE, there were a number of defects preventing international keyboard layouts (i.e. those other than “US English”) from working properly in the embedded console.  Those defects have been fixed, so now you can use the embedded console with international keyboards just fine.

We also added support for Unicode characters to the embedded console, making it easier for customers to get the output they expect regardless of where they happen to be.

Multi-select support in the File|Open dialog

With PowerSE 2.5.3, you can open multiple files in one folder at once by simply selecting the files you want before you click on the Open button.  This can be a big timesaver when you are working with modules containing many files!

Smarter variable Intellisense

When you enter a variable name in a script, it can be difficult to determine if you are entering the name of an existing variable or if you are creating a new variable.  Previous releases would sometimes complete a variable name incorrectly when you were in fact creating a new variable name.  This shouldn’t be a problem any longer, because we now allow you to enter new variable names and the auto-completion should only happen when you want it to happen.

Proper ps1xml file support

In PowerSE 2.5.3, if you are working with ps1xml files, you will now get proper Intellisense as well as auto-completion of xml elements as you would expect.

Fast clearing of the embedded console window

In today’s era of PowerShell, we all want to do more in less time, so much so that even typing in cls in the embedded console and pressing Enter can be cumbersome when you do it repeatedly.  PowerSE 2.5.3 allows you to clear the embedded console window at any time by simply pressing Ctrl+Del.

And more…

This is just a short list of some of the key changes we have made in this release.  There are others that I want to talk about, but I’m going to save a few for follow-up blog posts.  We’ve been spending a lot of time on PowerSE recently, and between our hard work and your great feedback, we’ve built a fantastic, best-in-class PowerShell script editor!  If you write PowerShell scripts, I encourage you to give this release a try, and be sure to let us know what you think!  Also, if you have any questions, feel free to leave me a note on my blog or pop over to www.devfarm.com and ask us directly in the chat window.  We’re always listening!

Thanks,

Kirk out.

Seasons of change: new Product Manager for PowerWF™ and PowerSE at Devfarm Software

I always enjoy this time of year.  There is something about the transition that happens over Labour Day weekend that always gets me excited.  Maybe it’s a lingering feeling of anticipation over the new year at school or university from years gone by, a feeling that I can still appreciate these days as I watch my kids getting excited about their education and the new activities they will sign up for this fall.  Regardless, it’s always a fun time of year for me.

This year though I have some extra reasons of my own to be even more excited.  As of this morning, I am now working as Product Manager for the PowerWF and PowerSE products at Devfarm Software!  I am absolutely thrilled about this new position!  Devfarm has a great team and a great set of products, and I’m really happy to be able to help them drive those products forward.

With this news, today marks the end of a month that included some vacation time, some time to step back and refocus, and some time for reflection on what to do next.  During this time I received a ton of support from friends and followers in the PowerShell community, and for that I am very grateful.  This support helped one particular sentiment that I came across stay with me:

You know for a (while) I (wondered if) going back to the amazing experience of (PowerShell) wouldn’t be a good idea, but really now I’ve come completely around because (software can be) stressful and hard to make but ultimately what makes (it) fun is the people that you work with, and the fact that (I’m) going to be working with a lot of the old gang, with a lot of friends, and obviously making some new friends is really the point of being here, so I’m extremely thrilled.1

This really represents how I have felt since my departure from my last job as Product Manager for PowerGUI.  I really love PowerShell as a technology, but as great as that technology is, it just wouldn’t be the same without the community that surrounds it.  PowerShell is blessed to have a tremendous community, and I am very, very proud to be able to continue to participate in that same community as a Product Manager for some really cool products that use PowerShell, as a PowerShell MVP, and as a geek who fell in love with technology a long time ago.

Now that I’ve found my new direction and focus, it’s time to get down to business.  Whether you’re a current user of PowerWF or PowerSE or someone who is interested in trying PowerWF or PowerSE, I’d love to connect with you to hear what you like (or don’t like) about these products as well as what you would like to see added to them in the future.  Feel free to reach out to me at any time either in my blog comments or by using the Contact Me form on my blog.  I’m really looking forward to working with you.

Kirk out.

1 Paraphrased from Peter Jackson’s speech on the first day of filming for “The Hobbit”; his exact speech can be heard here: http://www.youtube.com/watch?v=LqzJ1LFh6x0&hd=1&t=9m15s.

One for the road: Stepping away from PowerGUI®

Today was one of my most difficult days in my 7½+ year career at Quest Software.  The same week that I was given a performance raise (I got that email on Monday), this afternoon I got a phone call from the director over my business unit letting me know that my position has been cut effective immediately.  Part of a book balancing effort it seems –  funny (or not so much) how life works sometimes.

I’ve accomplished a lot while working at Quest, and spent a ton of professional and personal energy on the company and its products, particularly PowerGUI (far too much energy if you ask my wife, and today I must say I’m tending to agree).

Since I started working with the PowerGUI team at Quest back in 2007 (back in the version 1.0.x days) I have:

  • been awarded the Microsoft MVP award for my community support Windows PowerShell four years in a row
  • received recognition as a Quest Software expert in Windows Management (only 1% of the company employees have received this recognition)
  • provided feedback and direction over the product and its features through 3 major release cycles and many minor releases
  • supported the product and the community as a PowerPack developer, then as a PowerShell Solutions Architect, and most recently as the Product Manager (although I never could get those other positions backfilled so I ended up wearing all three hats most of the time)
  • released dozens of extensions for the product, including PowerPacks for platforms such as Active Directory, VMware, Hyper-V, and Exchange, and Add-ons such as the Script Editor Essentials Add-on or others for specific features such as script signing, transcription, the PowerShell blue console theme, and many more
  • pushed the number of commercial features in PowerGUI Pro from two when I took over as Product Manager to over six in the current version with many more on the way
  • initiated strategic partnerships with key enterprises such as NetApp and Intel and helped them create their own PowerPacks for their platforms
  • helped drive traffic to the powergui.org site through my blog and through social media as we grew the number of downloads from 100000 to over 1.2 million
  • provided feedback and direction to internal teams at Quest with PowerShell support in their products
  • successfully presented well-received PowerShell-focused sessions at many user groups and also at conferences such as Microsoft TechEd, the TEC conference, the PowerShell Deep Dive (a mini-conference in the TEC conference), and TechDays Canada
  • been elected as President for the PowerShellCommunity.org site
  • coordinated and provided direction over the first ever PowerShell Deep Dive conference

Unfortunately, most of that is now a legacy as it came to an abrupt end today.  I’m still a PowerShell MVP, and I will still be involved with the PowerShell community, however my work on PowerGUI has stopped for now.

Before I step back from this though, and before I reorganize/refocus my efforts onto more important things, I wanted to share one more new PowerGUI feature that I recently created for the community that I have spent so much time with these past 4 years.  I still have a strong affinity for PowerGUI and a lot of my heart and soul has gone into this product, and this feature is just a small example of that effort.  The new feature comes as part of the Call Stack Window add-on that I just published in the PowerGUI Add-on library.  Here’s a screenshot showing you what this add-on looks like in action:

PowerGUI Script Editor Call Stack Window

This add-on adds a call stack window to your PowerGUI Script Editor every time you start debugging a script. Working with a call stack while you debug anything beyond the most simple of scripts is essential because it provides you with a list of all nested calls that led up to the current line of script in your debug session. You can use this to determine where functions are being called from by setting a breakpoint inside a function and then walking up the call stack to see the script used to call the function. Also, this window has double-click support, so if you would like to go to any location in the call stack, simply double-click on the location you wish to see and the add-on will take you there, even if the file in question isn’t open at the time.

I was considering putting this feature in the Pro version in a future release, but that is beyond my control now so I decided I’d share what I have today and let you guys have fun with it.  Since I created the feature in this add-on, it’s been an incredibly useful feature to me and I hope you guys enjoy it as well.  To get this Add-on, simply select Tools | Find Add-ons Online in your PowerGUI Script Editor and search for “Call Stack”.

That will most likely be my last PowerGUI-centric post for a while, and it will be my last post for at least a week while I take a much needed vacation before moving on to new things.

Thank you for your continued support through the past four years.  I hope this post finds you well.

Sincerely,

Kirk Munro
Former Product Manager of PowerGUI Pro and PowerGUI

P.S. If you are in need of someone with my skills, either as a Product Manager, a PowerShell MVP, an expert in Windows management (with a strong focus on Active Directory and Exchange although I’ve also gotten deeply involved in virtualization with Hyper-V and VMware as well), a social media/community site manager, or as a freelance writer, my schedule has all of a sudden become much less busy and I’m interested in filling up that time with new work once I come back from vacation, so please get in touch.

PowerGUI® 3.0 Hotfix: Double-clicking on a ps1, psm1, or psd1 file to open the Script Editor shows the Start Page as the active page in the Script Editor

This article describes an issue that was introduced into both PowerGUI and PowerGUI Pro when version 3.0 was released and provides a recommended solution to that issue.

Problem

While the PowerGUI Script Editor is closed, double-clicking on a ps1, psm1 or psd1 file or right-clicking on one of those file types and selecting “Open with PowerGUI Script Editor” will open the file you selected in the Script Editor as expected; however the Start Page will appear as the active tab in the Script Editor instead of the file you opened.

Affected Products

  • PowerGUI 3.0 (freeware)
  • PowerGUI Pro 3.0

Solution

To resolve this problem, a new version of the Script Editor Essentials Add-on has been released.  This version (3.0.0.75) includes a modification to the Script Editor behaviour such that any file you use to open the PowerGUI Script Editor will immediately become the active file.

To install this hotfix, please follow these steps:

If you are connected to the Internet

  1. Open the PowerGUI Script Editor.
  2. Run the following command from the embedded PowerShell console:
    $oldState = $PGSE.Configuration['/CollectAndSendInformation']
    if (-not $oldState) {
        $PGSE.Configuration['/CollectAndSendInformation'] = $true
    }
  3. Select Tools | Find Add-ons Online to show the Find Add-ons Online dialog.
  4. Type “Script Editor Essentials” into the text box at the top of the Find Add-ons Online dialog.
  5. Click on the Search button.
  6. Once the search results are returned, Select the Script Editor Essentials Add-on if it is not already selected.
  7. Click on the Install button to download, install and load the Script Editor Essentials Add-on.
  8. Once the Script Editor Essentials Add-on is installed, run the following command from the embedded PowerShell console:

    if (-not $oldState) {
        $PGSE.Configuration['/CollectAndSendInformation'] = $false
    }
  9. Close the PowerGUI Script Editor.

If you are not connected to the Internet

  1. Open your web browser and browse to http://www.powergui.org/entry.jspa?externalID=2952.
  2. Follow the steps outlined in the “Manual install” section on that page, copying the Add-on.ScriptEditorEssentials.zip between machines as appropriate.
  3. Close the PowerGUI Script Editor.

At this point you should be able to double-click on ps1, psm1 or psd1 files if you file association is set up and have those files open in the PowerGUI Script Editor as the active document.

Feedback

This solution is being provided based on the feedback of users who notified us about the issue two days ago on the forums.  If you have any questions about this solution, please let us know in the forums or in the comments on this post.

Thanks!

Kirk out.

PowerGUI® Pro 3.0: Mobile Systems Management Using MobileShell

In case you missed the announcement last Friday, PowerGUI Pro 3.0 was released to the web.  With this release we included a new feature that I’m really excited about: Mobile Systems Management Using MobileShell.  We’ve had MobileShell for quite a while, but prior to this release you could only use it to invoke your favorite scripts or commands from modules associated with your user account as well as ad hoc commands you wanted to run.  Here’s a screenshot tour showing you what this interface would look like on a handheld device:

PowerGUI Pro MobileShell - Favorites - 1 of 4   PowerGUI Pro MobileShell - Favorites - 2 of 4   PowerGUI Pro MobileShell - Favorites - 3 of 4   PowerGUI Pro MobileShell - Favorites - 4 of 4

As you can see from this, the capabilities in this version were very cool (what’s not to like about running PowerShell from your smartphone), but they were somewhat limiting as well because you couldn’t really work with a management user interface from your handheld device this way.

PowerGUI Pro 3.0 changes all of that, by including a new management interface for MobileShell that is based on PowerPacks (in case you don’t know already, PowerPacks are extensions for the PowerGUI Administrative Console that provide a management experience much like MMC, but that are driven entirely by Windows PowerShell commands and scripts).  With 3.0 we’ve provided a new mobile interface for MobileShell that allows you to use PowerPacks associated with your AD user account or groups that you are a member of from your mobile device!  Also, we’ve made the management experience even more responsive at the same time, so now you can do more with MobileShell and it will do it more quickly than before!  All you need is a mobile device with a WebKit-enabled web browser (sorry, that means no BlackBerry 5.x or Windows Phone 7 support for now).

Here’s a screenshot tour showing you how this new experience can be used to do something very simple like unlock a user account:

PowerGUI Pro MobileShell ScreenShot Tour - 1 of 12   PowerGUI Pro MobileShell ScreenShot Tour - 2 of 12   PowerGUI Pro MobileShell ScreenShot Tour - 3 of 12   PowerGUI Pro MobileShell ScreenShot Tour - 4 of 12

PowerGUI Pro MobileShell ScreenShot Tour - 5 of 12   PowerGUI Pro MobileShell ScreenShot Tour - 6 of 12   PowerGUI Pro MobileShell ScreenShot Tour - 7 of 12   PowerGUI Pro MobileShell ScreenShot Tour - 8 of 12

PowerGUI Pro MobileShell ScreenShot Tour - 9 of 12   PowerGUI Pro MobileShell ScreenShot Tour - 10 of 12   PowerGUI Pro MobileShell ScreenShot Tour - 11 of 12   PowerGUI Pro MobileShell ScreenShot Tour - 12 of 12

As you can see from this screenshot tour, this user experience is much richer and it gives you a full management console on the go, allowing you to respond to issues you are responsible for no matter where you are or what time it is.  It’s also configurable using role-based access control (RBAC), so you can assign different PowerPacks to different MobileShell users based on their AD user and group membership.  Even better, we make configuration of this functionality even easier by providing you with a MobileShell Administration PowerPack as part of the PowerGUI Pro 3.0 package.

If you’re interested in trying this functionality out, here’s what you need to do:

  1. Make sure you have an IIS server ready where you can install it.
  2. Install MobileShell on the IIS server.  The MobileShell installer is pretty self-explanatory.
  3. If you didn’t add the MobileShell users during the installation, add anyone who you want to be able to access MobileShell to the PowerGUI MobileShell Users group (note: there may be a delay once you add users before they have access, up to 15 minutes).
  4. Install the PowerGUI Pro Admin Console on the IIS Server with the MobileShell Administration PowerPack.
  5. Open the PowerGUI Pro Admin Console.
  6. In the MobileShell Administration PowerPack, select Users and then click on the Add User action to add your user account.  Repeat this for each user account you want to provide access to.
  7. Select the PowerPacks node and then click on the Publish PowerPack action.  Provide the path for the PowerPack you want to expose via MobileShell and then click on OK.  Repeat this for each PowerPack you want to expose via MobileShell.
  8. Go back to the Users node, select the users you want to provide PowerPack access to, and then click on Assign PowerPack to assign one of the PowerPacks you have published to the selected users.

At this point you should be ready to go with your first MobileShell management experience.  Point your WebKit-enabled web browser to https://serverName/MobileShell/Admin, sign-in, and you’re off and running!

Note: PowerPacks don’t support the new MobileShell management experience by default.  We made the decision to make it off by default because we wouldn’t be able to tell which PowerPacks would display UI on the web server (such as a message box) reliably.  Any PowerPack can support this new experience though, they just need to be updated to suppor tit. The core PowerPacks that ship with PowerGUI Pro have been updated to support this new management experience so you’re already enabled with a rich mobile management experience for Active Directory, VMware, Exchange, and Windows management.  I’ll write another post later that describes what is required to turn on mobile management for a PowerPack.

That’s it for this post.  If you have any questions, don’t hesitate to ask.

Kirk out.