Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
like image 878
Mark Fulton Avatar asked Dec 11 '22 21:12

Mark Fulton


2 Answers

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.

like image 75
Ansgar Wiechers Avatar answered Apr 29 '23 01:04

Ansgar Wiechers


Try

powershell ./RunCommandLine.ps1
like image 41
Logan Jones Avatar answered Apr 29 '23 01:04

Logan Jones