错误:术语"./RunCommandLine.ps1"未被识别为cmdlet,函数,脚本文件或可操作程序的名称

Mar*_*ton 1 powershell ms-release-management

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

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文件应该在哪里?我在当地和服务器上搜索但却一无所获.有没有遇到过这个?

错误信息:

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
Run Code Online (Sandbox Code Playgroud)

Ans*_*ers 7

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

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

$PWD.Path
(Get-Location).Path
(Resolve-Path '.').Path
Run Code Online (Sandbox Code Playgroud)

基本上有3种方法可以解决这个问题:

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

    Push-Location 'C:\some\folder'
    .\RunCommandLine.ps1
    Pop-Location
    
    Run Code Online (Sandbox Code Playgroud)
  • 使用完整路径运行PowerShell脚本:

    & 'C:\some\folder\RunCommandLine.ps1'
    
    Run Code Online (Sandbox Code Playgroud)

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


Log*_*nes 5

尝试

powershell ./RunCommandLine.ps1
Run Code Online (Sandbox Code Playgroud)