Powershell需要很长时间才能完成;无法完全覆盖默认提示功能

时间:2015-10-02 21:17:00

标签: powershell powershell-v4.0

我不知道我的Powershell发生了什么。我有一个shell注册表项,允许我在目录中打开一个Powershell窗口。内容是:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -NoExit 

这是我自定义的提示功能:

function prompt {
    Write-Host ("on ") -NoNewLine -ForegroundColor White
    Write-Host ("$env:COMPUTERNAME") -NoNewLine -ForegroundColor Gray
    Write-Host (" in ") -NoNewLine -ForegroundColor White
    Write-Host ($(Get-Location)) -ForegroundColor Gray
    Write-Host ("$") -NoNewLine -ForegroundColor Magenta

    return "> ";
}

它应该返回类似

的内容
  

在C:\

中的PC-NAME上      

$>

但是,它会返回:

  

在C:\

中的PC-NAME上      

$> PS C:>

我的Powershell有什么问题吗?如何获得更多调试信息以帮助您?

1 个答案:

答案 0 :(得分:0)

我可以通过在安装的PSReadline模块中注释掉一些函数来解决这个问题。该模块会在当前提示的末尾添加一个`b,将用户提示附加到它,并在关闭Powershell时恢复默认提示。