I cannot work out how to pass arguments that contain folders with spaces using msdeploy.exe and PowerShell v4.
Sample Powershell Script
When invoking commands PowerShell does some auto quoting that does not work well with MSDeploy. There are a couple of ways to avoid the auto quoting. One is to use the Start-Process cmdlet where you can specify the exact command line that you want but it can become a bit tedious to get the output of the new process to appear as output of the PowerShell script that you are running.
Another option is to use the --%
specifier to turn off PowerShell parsing. However, doing that will not allow you to use variables in the command line because - well, parsing has been turned off. But you can get around this by using the Invoke-Expression cmdlet to first build the command line including the --%
and whatever variables you want and then let PowerShell evaluate it:
$fl1 = "D:\space space\a.txt";
$fl2 = "D:\space space\b.txt";
$arguments = "-verb:sync -source:filePath=""$fl1"" -dest:filePath=""$fl2"""
$commandLine = 'msdeploy.exe --% ' + $arguments
Invoke-Expression $commandLine