A few months ago, after re-installing my workstation operating system and getting all my applications and tools loaded, I fire up Operations Manager Command Shell.  Since I use the tab expansion function frequently, I noticed immediately that for some odd reason the Command Shell would paused for ~30 seconds every time I used the tab completion function.  I had to remind myself never to use it or I’d be twiddling my thumbs for a while.  Sometimes it’s quicker to just close Command Shell and launch it again, but usually there is history saved which I don’t want to lose.  So I wait…and wait.  Very frustrating.

Lincoln Atkinson created a workaround for this, which I stumbled across on the Technet forum.  This was such a wonderful find, I feel like I should spread the news.  Run the following script, or add it to your $profile, and tab away!

$tabExpand = (get-item function:\tabexpansion).Definition
if($tabExpand -match 'try {Resolve-Path.{49}(?=;)')
{
   $tabExpand = $tabExpand.Replace($matches[0], "if((get-location).Provider.Name -ne 'OperationsManagerMonitoring'){ $($matches[0]) }" )
   invoke-expression "function TabExpansion{$tabExpand}"
}

Thanks Lincoln!


Note

Some say this tab expansion delay issue is only observed with Powershell v2, but I was running Powershell v1 at the time and adding this script to my profile resolved the tab expansion delay.