4
Vote

Error with "Get-Content Function:TabExpansion" in PS V4

description

Trying PowerTab in Windows 8.1 preview.
Installation completes and [Tab] is working, but when PowerTab is loading error was occured (path "Function:\TabExpansion" not found).
Have seen same issue for V3 version, but " -ErrorAction SilentlyContinue" have no effect (I'm not familiar with PS and may be used it erroneously).
Windows PowerShell
(C) Корпорация Майкрософт, 2013. Все права защищены.

Get-Content : Не удается найти путь "Function:\TabExpansion", так как он не существует.
C:\Users\XXX\Documents\WindowsPowerShell\Modules\PowerTab\PowerTab.psm1:17 знак:20
+ $OldTabExpansion = Get-Content Function:TabExpansion
+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Function:\TabExpansion:String) [Get-Content], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand

PowerTab version 0.99.6.0 PowerShell TabExpansion Library
Host: ConsoleHost
PowerTab Enabled: True
PS C:\Users\XXX> get-host


Name             : ConsoleHost
Version          : 4.0
InstanceId       : 34ad679a-dcf3-4195-bf68-ca37d523679c
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : ru-RU
CurrentUICulture : ru-RU
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

comments

Maximus5 wrote Oct 20, 2013 at 7:30 PM

Seems like this project is abandoned? I'm not sure my solution is correct, but at least it does not shows errors. PowerShell v3 does not have TabExpansion function, it was renamed to TabExpansion2. Changed few lines in PowerTab.psm1:
#########################
## Cleanup
#########################

$OldTabExpansion = Get-Content Function:TabExpansion -ErrorAction "SilentlyContinue"
$OldTabExpansion2 = Get-Content Function:TabExpansion2 -ErrorAction "SilentlyContinue"
$Module = $MyInvocation.MyCommand.ScriptBlock.Module 
$Module.OnRemove = {
  if ($OldTabExpansion -ne $null) {
    Set-Content Function:\TabExpansion -Value $OldTabExpansion
  }
  if ($OldTabExpansion2 -ne $null) {
    Set-Content Function:\TabExpansion2 -Value $OldTabExpansion2
  }
}

adlermedrado wrote Dec 5, 2013 at 7:47 PM

MaximuS solution worked for me.
Thank you.

rthauvin wrote Aug 14, 2014 at 1:06 AM

Worked for me too. Thanks !