首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在运行时插入到Powershell程序中的其他空格

在运行时插入到Powershell程序中的其他空格
EN

Stack Overflow用户
提问于 2015-03-13 22:40:30
回答 1查看 50关注 0票数 0

我有一个“古怪”的PowerShell问题,我希望有人能帮我解决。这可能不是一个真正的PowerShell问题,但我已经遇到了两次,而且两次都是使用PowerShell。

今天,我下载了PSUnit。我按照安装说明操作,其中包括将profile.ps1复制到我的PowerShell配置文件目录中。文件中的第一行是:

代码语言:javascript
复制
$PSUnitPath = "D:\Data\PSUnit"

完成安装后,当我在PowerShell ISE中打开PSUnit测试时,收到以下错误:

代码语言:javascript
复制
The term ' $ P S U n i t P a t h ' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct an
d try again.
At C:\Users\sfhostingadmin.SCRUMDOMAIN\Documents\WindowsPowerShell\profile.ps1:3 char:24
+  $ P S U n i t P a t h  <<<<   =   " D : \ D a t a \ P S U n i t "   # M o d i f y   t h i s   p a t h   t o   m a t c h   y o u r   l o c a l   P o w e r S h e l l   i n s t a l l a t i o n   p a t h 
    + CategoryInfo          : ObjectNotFound: ( $ P S U n i t P a t h :String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

注意,它在所有字母之间插入了一个空格。当我在文本编辑器中打开文件时,多余的空格不在那里。

只需打开Powershell命令窗口时,即不涉及ISE时,也会出现此错误。

我不认为这是PSUnit的问题。我以前在一个不涉及PSUnit的不同PowerShell程序上有过一次这样的经历。当时我解决这个问题的唯一方法是打开一个新文件,然后重新键入PowerShell程序。

EN

回答 1

Stack Overflow用户

发布于 2015-03-13 22:52:11

这是一个编码问题。文件采用双字节字符编码(例如UCS-2高字节顺序),但ISE将其解释为单字节字符(例如UTF-8)。通常,当字节顺序标记( Byte Order Mark,BOM)丢失或者编辑器或程序不理解双字节编码时,就会出现这种情况。

在Notepad++中打开该文件,然后使用编码菜单将其更改为UTF-8。没有BOM的UTF-8也可以。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29035096

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档