How do you call msdeploy from powershell when the parameters have spaces?

后端 未结 9 1247
忘了有多久
忘了有多久 2020-11-30 05:52

I\'m running into a problem with spaces in my parameters that I try to send into msdeploy from a powershell script.

There are a number of other related articles but

9条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-30 06:30

    Here is another approach derived from the input below.

    $msdeploy = "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe";
    
    $command = "-verb:sync";
    
    $sourcePath = "C:\aa aa\";
    $source = $("-source:contentPath=`"{0}`"" -f $sourcePath);
    
    $destPath = "C:\aa"
    $destination = $("-dest:contentPath=`"{0}`" -f $destPath);
    
    $msdeploycommand = $("`"{0}`" {1} {2} {3} -verbose" -f $msdeploy, $command, $source, $destination);
    
    cmd.exe /C "`"$msdeploycommand`"";
    

    This caters for the MSDeploy.exe being in its default installation folder which contains spaces. Hence the wrapping with the escape character (`).

提交回复
热议问题