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

后端 未结 9 1262
忘了有多久
忘了有多久 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:26

    All of the above did not work for me, this is the solution that worked:

    # get msdeploy exe
    $MSDeploy = ${env:ProgramFiles}, ${env:ProgramFiles(x86)} |
            ForEach-Object {Get-ChildItem -Path $_ -Filter 'MSDeploy.exe' -Recurse} |
            Sort-Object -Property @{Expression={[version]$_.VersionInfo.FileVersion}} -Descending |
            Select-Object -First 1 -ExpandProperty FullName
    
    #build deploy command        
    $deplyCmd = """""$MSDeploy"" -verb:sync -dest:iisApp=""Default Web Site"" -enableRule:DoNotDeleteRule -source:iisApp=""$ExtraWebFilesFolder"""    
    
    #execute    
    &cmd /c $deplyCmd
    

提交回复
热议问题