Error: The term './RunCommandLine.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program
Asked Answered
O

2

8

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

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

Error Message:

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
Oraleeoralia answered 10/9, 2015 at 16:25 Comment(1)
O
11

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

There are basically 3 ways to deal with the issue:

  • 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
    
  • 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.

Orola answered 11/9, 2015 at 9:16 Comment(0)
D
5

Try

powershell ./RunCommandLine.ps1
Derisible answered 10/9, 2015 at 16:33 Comment(2)
No. I assumed it was in the start directory. Otherwise "./" doesn't make any sense. If you open up a powershell prompt as administrator, drop to the root of your C: drive and run "Get-ChildItem -Recurse | Where-Object { $_.Name -match 'RunCommandLine.ps1' }" it should find it. It'll spit some permissions errors, but it'll still keep looking through what it can.Derisible
Thanks for the help but too many access denied! haha This works... dir /b /s c:\RunCommandLine.ps1Oraleeoralia

© 2022 - 2024 — McMap. All rights reserved.