What is up with this PowerShell command line quoting/escaping?

后端 未结 3 639
别跟我提以往
别跟我提以往 2021-02-13 20:40

I obviously don\'t know what I\'m doing.

I have finally got this PowerShell command to work. But I can\'t figure out why it works.

My concern is the final \"\" c

3条回答
  •  耶瑟儿~
    2021-02-13 20:56

    I finally found out how to do this. Here is a sample script:

    $src = 'C:\sandbox\Test Folder\A'
    $dest = 'C:\sandbox\Test Folder\B'
    $msdeploy = Get-Command 'C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe'
    $command = "& `$msdeploy --% -verb:sync -source:contentPath=""$src"" -dest:contentPath=""$dest"""
    $sb = $ExecutionContext.InvokeCommand.NewScriptBlock($command)
    & $sb
    

提交回复
热议问题