【问题标题】:Why does my powershell prints an error on startup?为什么我的 powershell 在启动时打印错误?
【发布时间】:2015-07-15 14:46:52
【问题描述】:

加载 PowerShell 控制台时出现以下错误:

The string is missing the terminator: '.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString

所有配置文件位置都通过 TestPath $PROFILE 报告错误,以及 Powershell ISE 配置文件文件的位置。

PS C:\Windows\System32> Test-path $profile.AllUsersAllHosts
False
PS C:\Windows\System32> Test-path $profile.AllUsersCurrentHost
False
PS C:\Windows\System32> Test-path $profile.CurrentUserAllHosts
False
PS C:\Windows\System32> Test-path $profile.CurrentUserCurrentHost
False
PS C:\Windows\System32> Test-path "C:\Users\bleykekhman\Documents\WindowsPowerShell\Microsoft.PowerShelllSE_profile.psl"
False
PS C:\Windows\System32> Test-Path $PSHOME\Microsoft.PowerShelllSE_profile.ps1
False

如果我根本没有任何配置文件脚本,我的问题是什么导致了错误消息?

【问题讨论】:

  • 出于好奇,为什么要关闭?
  • 这当然很奇怪。在黑暗中拍摄,但您的 PowerShell 快捷方式的目标是什么样的。和你上一个问题一样吗?这是 x64 还是 x86 控制台?我想知道你是否在这里有个人资料? C:\Windows\SysWOW64\WindowsPowerShell\v1.0
  • FWIW 我认为您的问题很清楚。你可以用实际的文本替换图像吗?
  • 在命令提示符下运行powershell.exe 时是否遇到同样的错误?
  • @Matt - 你就在现场。快捷方式是C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -PSConsoleFile "D:\Program Files (x86)\Microsoft Team Foundation Server 2013 Power Tools\tfshell.psc1" -noexit -command ". 'D:\Program Files (x86)\Microsoft Team Foundation Server 2013 Power Tools\TFSS,它显然是拙劣的。我将其更改为%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe,它工作正常。请安排您的评论作为回复,我将给予充分的信任。

标签: powershell


【解决方案1】:

因此,您已经了解了验证您没有可供 PowerShell 加载的配置文件的重要基础。还有一个地方可以配置为加载代码。我会检查您的 PowerShell.exe 快捷方式,看看您是否有任何开关,例如 -File-NoExit

我确定我的快捷方式是普通的,因为我刚刚重新安装了我的操作系统并更新到 v4.0

  • 目标:%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe
  • 开始于:%HOMEDRIVE%%HOMEPATH%

检查您的是否有所不同。

AnsgarWiechers 以不同的方式提出相同的建议。从 cmd 提示符下运行 powershell,无需任何开关。这会导致回到快捷方式。

【讨论】:

  • 不同的是,愚蠢的我——应该马上检查一下。似乎安装 Team Foundation Power Tools 以某种方式成功地破坏了快捷方式 - 显然缺少要运行的脚本名称并关闭单引号和双引号。我重置了快捷方式,现在可以正常使用了。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-04-08
  • 2020-04-23
  • 2014-02-21
  • 2021-04-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多