Thursday, April 10, 2014

Powershell not responsive on tab

Powershell is everywhere now. Exchange, SCOM etc.. you name it.

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 staring at the screen 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. :(
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}"

No comments:

Post a Comment