Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Azure WorkerRole上运行PowerShell命令时出错_Powershell_Azure - Fatal编程技术网

在Azure WorkerRole上运行PowerShell命令时出错

在Azure WorkerRole上运行PowerShell命令时出错,powershell,azure,Powershell,Azure,我正在尝试在Windows Azure角色上运行启动任务cmd脚本 以下是命令文件脚本的两行: powershell $command = "set-executionpolicy Unrestricted" powershell $command = ".\setupAgent.ps1" -NonInteractive >; out.txt 现在的问题是,我从命令shell中得到一条错误消息,上面说: D:\Users\UserAccount>∩╗┐powershell

我正在尝试在Windows Azure角色上运行启动任务cmd脚本

以下是命令文件脚本的两行:

powershell $command = "set-executionpolicy Unrestricted"    
powershell $command = ".\setupAgent.ps1" -NonInteractive >; out.txt
现在的问题是,我从命令shell中得到一条错误消息,上面说:

D:\Users\UserAccount>powershell $command = "set-executionpolicy Unrestricted"
'powershell' is not recognized as an internal or external command,
operable program or batch file.
看起来好像使用了某种不同的代码页或链接,因为这些特殊字符不在我的cmd文件中。cmd文件是通过VS 2012 Ultimate在Windows 8上创建的


你有什么主意吗,我怎么能在命令开始的时候把那些特殊的角色打发掉?如果我通过远程桌面将命令从cmd文件复制到控制台,效果会很好

用VS 2012 Ultimate打开你的
whatever.cmd
文件。单击
文件
->
将whatever.cmd另存为
->在对话框的
[Save]
按钮旁边有一个小箭头。它将显示一个菜单,该菜单具有选项
使用编码保存


选择它。现在从可用编码列表中选择“US-ASCII代码页20127”。

谢谢,这就是解决方案+1.您能详细说明为什么需要这种编码吗?Visual Studio默认情况下使用BOM(字节顺序标记-文件的第一个字节)以UTF-8保存文件。操作系统(包括Windows)在执行
script
文件时无法识别这一点。这会导致保存在UTF-8中并带有BOM的任何脚本文件失败。一般的经验法则是,要由操作系统执行的脚本文件(DOS批处理文件、PS文件、BASCH脚本、Peral、PHP等)必须采用本机ASCII编码。