错误:术语“./RunCommandLine.ps1"未被识别为 cmdlet、函数、脚本文件或可运行程序的名称 [英] Error: The term './RunCommandLine.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program

查看:35
本文介绍了错误:术语“./RunCommandLine.ps1"未被识别为 cmdlet、函数、脚本文件或可运行程序的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用 Microsoft Release Management 2013 部署到开发/测试/生产.构建/部署服务器是 MS2012.应用服务器是 MS2008.我让它工作和部署,但昨天我开始收到这条消息.它所做的一切都是使用运行命令行"在应用程序服务器上运行一个批处理文件,该文件进行备份、设置 Windows 服务启动类型、停止服务等.如果我直接在应用程序服务器上运行批处理文件,它只会运行美好的.我根据本文添加了更详细的日志记录,但没有收集其他信息以进行调试.Powershell 最近也没有在服务器上更新.

We are using Microsoft Release Management 2013 to deploy to Dev/Test/Prod. The Build/Deploy Server is MS2012. The Application Servers are MS2008. I had it working and deploying but then yesterday I started getting this message. All its doing is using the 'Run Command Line' to run a batch file on the Application Server that makes a backup, sets windows services startup type, stops services, etc. If I run the batch file directly on the Application Server it runs just fine. I added more detailed logging per this article but no additional information was gathered in order to debug. Powershell has not been updated lately on the servers either.

http://blogs.msdn.com/b/visualstudioalm/archive/2013/12/13/how-to-enable-detailed-logs-and-collect-traces-from-various-release-management-components.aspx

有人知道 *.ps1 文件应该在哪里吗?我搜索了本地和服务器,但一无所获.有人遇到过这种情况吗?

Anyone know where the *.ps1 files are supposed to be? I searced local and server but found nothing. Anyone ever encounter this?

错误信息:

The term './RunCommandLine.ps1' 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 and try again.
At line:1 char:21
+ ./RunCommandLine.ps1 <<<<  -FilePath '\\unc-path\batchfile.bat' -Arguments ''
    + CategoryInfo          : ObjectNotFound: (./RunCommandLine.ps1:String) [] , CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

推荐答案

当运行像 ./RunCommandLine.ps1 这样的脚本时,脚本应该在当前工作目录 (.).不过,根据您执行该语句的环境,工作目录可能不是您所期望的.

When running a script like ./RunCommandLine.ps1 the script is expected to be in the current working directory (.). Depending on the environment from which you're executing that statement the working directory may not be what you expect, though.

以下是一些命令,可让您在以与脚本相同的方式运行时确定当前工作目录:

Here are some commands that allow you to determine the current working directory when run the same way as your script:

$PWD.Path
(Get-Location).Path
(Resolve-Path '.').Path

基本上有3种方法来处理这个问题:

There are basically 3 ways to deal with the issue:

  • 指定 PowerShell 脚本相对于当前工作目录的路径.
  • 将当前工作目录更改为 PowerShell 脚本所在的位置:

  • Specify the path to your PowerShell script relative to the current working directory.
  • Change the current working directory to the location of the PowerShell script:

Push-Location 'C:\some\folder'
.\RunCommandLine.ps1
Pop-Location

  • 使用完整路径运行 PowerShell 脚本:

  • Run the PowerShell script with its full path:

    & 'C:\some\folder\RunCommandLine.ps1'
    

    调用运算符 (&) 允许您运行定义为字符串的路径(例如,因为它们包含空格),否则只会被回显.

    The call operator (&) allows you to run paths that are defined as strings (for instance because they contain spaces), which would otherwise just be echoed.

    这篇关于错误:术语“./RunCommandLine.ps1"未被识别为 cmdlet、函数、脚本文件或可运行程序的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆