PowerShell & MSDeploy - Arguments with Spaces

后端 未结 4 1072
予麋鹿
予麋鹿 2021-01-07 10:39

I cannot work out how to pass arguments that contain folders with spaces using msdeploy.exe and PowerShell v4.

Sample Powershell Script



        
4条回答
  •  忘掉有多难
    2021-01-07 11:25

    I used the suggestion from the following: How do you call msdeploy from powershell when the parameters have spaces?

    To derive a "cleaner" solution.

        $msdeploy = "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe";
    
        write-warning "WITHOUT SPACE"
        $fl1 = "d:\nospace\a.txt"
        $fl2 = "d:\nospace\b.txt"
    
        $md = $("`"{0}`" -verb:sync -source:filePath=`"{1}`" -dest:filePath=`"{2}`"" -f $msdeploy, $fl1, $fl2)
        cmd.exe /C "`"$md`""
    
        write-warning "WITH SPACE"
        $fl1 = "d:\space space\a.txt"
        $fl2 = "d:\space space\b.txt"
    
        $md = $("`"{0}`" -verb:sync -source:filePath=`"{1}`" -dest:filePath=`"{2}`"" -f $msdeploy, $fl1, $fl2)
        cmd.exe /C "`"$md`""
    

提交回复
热议问题