How to write an msdeploy runcommand command that contains strings - command-line

Hi I'm trying to write an msdeploy command that contains two strings within the runcommand part of the command.
msdeploy.exe -verb:sync -source:runCommand="^"c:\opensesame\opensesame.cmd^" ^"c:\windows\system32^"" -dest:auto
I was trying to escape the quotes with the carats.
Basically what's suppose to happen is opensesame is called and the path is passed to it so it can open the calculator.
I'm guessing I don't have the right escape character?

If runCommand is not given a full path (and only a full path) to a bat or cmd file, it will execute the command as-is on the server without uploading your bat/cmd file first. If you want to upload the script before executing it, you'll need to bake your parameters into the script and pass it without arguments to runCommand.

Related

Fill Powershell Interactive Prompt from .csv

I am trying to run a .jar file from Powershell that requires the user to input four parameters through Command Prompt after executing the .jar. Each parameter is inputed as a new line. I would like to automatically read these parameters in from a .csv where each line contains one parameter.
I currently run the .jar by calling java -cp some.jar. The .csv and .ps1 are in the same directory.
I know with Shell this could be done with cat parameters.csv |. Is there an equivalent in PS? This question is related but does not deal with reading a .csv.

Launch external program with multiple commands via Powershell

I am currently attempting to launch a different console (.exe) and pass multiple commands; while starting and entering a command works just fine, I haven't been able to find out how multiple ones can be entered via powershell.
& "C:\Program Files\Docker Toolbox\start.sh" docker-compose up -d --build
The given command works fine, but as mentioned I need to pass more than one command - I tried using arrays, ScriptBlocks and different sequences, though to no avail.
Edit:
Noticed that the docker build has a -f tag which allows me to specify a file; however, the issue now seems to be that the executed cmd removes all backslashes & special characters, rendering the path given useless.
Example:
&"C:\Program Files\Docker Toolbox\start.sh" 'docker-compose build -f
path\to\dockerfile'
will result in an error stating that "pathtodockerfile" is an invalid path.
Your start.sh needs to be able to handle multiple arguments. This doesn't look like a PowerShell question
Turns out that it was easier than expected; Solved it by executing a seperate file that contained the two commands needed and passing it to the start.sh file.
&"C:\Program Files\Docker Toolbox\start.sh" './xyz/fileContainingCommands.sh'

How to run Powershell file (having extension .ps1) using jmeter?

I want to execute .ps1 file in jmeter. I have pass the parameter as in image,but in output facing errors.The filename, directory name, or volume label syntax is incorrect.
Though the filename, directory name are correct.
Here is your problem:
Remove that quotation mark and everything should start working as expected
In general, you are making things overcomplicated.
Why do you need these cmd /c? Why just don't call powershell directly?
Normally powershell is in Windows PATH, there is no need to provide full path to it
So configure your OS Process Sampler as:
Command: powershell
Parameter: D:\Software\apache=jmeter-3.0\apache-jmeter-3.0\bin\TIP.ps1
See How to Run External Commands and Programs Locally and Remotely from JMeter article for more information on invoking 3rd-party processes from your JMeter test.
I know this is an old thread but since the response was not correct for me I found the solution to be this:
Using the OS Process Sampler you need to add as command powershell.exe and as variables exactly the following:
-executionpolicy
bypass
-file
fullpathToYourScript.ps1
This worked perfectly fine for me.

TFSBuild Powershell step turning script arguments into strings. How to avoid this?

I've configured the following arguments in a Powershell build step: -protocol:http -portsToOpen 9512,9513,9512.
Once TFSBuild runs the whole script, it throws the following error:
"System.Int32[]". Error: "Cannot convert
"9512,9513,9515" to "System.Int32"
The problem is TFSBuild is running the script sorrounding 9512,9513,9515 with quots (i.e. '9512,9513,9515').
Is there any solution for this? One possible workaround would be running powershell.exe from a Command build step... But I'd like to know if there's some direct solution to this issue.
I don't use TFS but I can tell you PowerShell is parsing that as an integer array (System.Int32[]) and trying to pass that as an argument to -portsToOpen
If you don't have variables on that line you could use the stop parsing operator --% as that
directs Windows PowerShell to refrain from interpreting input as Windows PowerShell commands or expressions.
icacls X:\VMS --% /grant Dom\HVAdmin:(CI)(OI)F
You could also actually put it in quotes so that PowerShell just treats it as a string. I could not find the documentation to back up how it expects input for that parameter so I am not sure.

MSBuild from Powershell

I'm trying to run a Sync from MSBuild (From Powershell) that also includes Pre Sync Commands.
I am unable to get the commands right. I've tried multiple ways, but the final way I'm up to is :
[string[]]$msdeployArgs = #(
"-verb:sync",
"-preSync:runCommand='$preSyncCommand',waitInterval=30000",
"-source:dirPath=$sourceFolder",
"-dest:computerName=$serverName,userName=$username,password=$password,authType=basic,dirPath=$serviceFolder",
"-postSync:runCommand=$postSyncCommand,waitInterval=30000"
)
& "C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe" $msdeployArgs
I get the following error.
Error: Unrecognized argument
'"-preSync:runCommand='F:\Projects\Unleashed\Release_Scripts\WindowsServices\deployTopShelfServicePreCommands.cmd
Unleashed.Maintenance.JobScheduler
C:\MyCompany\Services\MyCompany.Maintenance.JobScheduler',waitInterval=30000"'.
All arguments must begin with "-".
Note that after the PreSyncCommand, is params that I want to pass to the CMD file (For it to know where to uninstall the existing service from etc.
I've ran that params via EchoArgs.exe, and the args are fine.
If it matters (It might), I'm running the powershell script from TeamCity.
I've found the issue. As it turns out, it isn't powershell with the issue, but MSDeploy. MSDeploy as far as I can see does not allow you to pass batch files with parameters. Removing the parameters works fine (But then you need to hardcode them in your batch file, or work out some other way of generating the bat files on the fly).