Powershell Command Processing (Passing in Variables)

后端 未结 5 1936
孤独总比滥情好
孤独总比滥情好 2021-02-15 23:21

I\'m creating a Powershell script to deploy some code and part of the process is to call a command-line compression tool called RAR.EXE to back-up some folders.

I\'m at

5条回答
  •  情话喂你
    2021-02-16 00:03

    I have had problems with the & call operator in the past when trying to invoke executable type commands like you are trying. Not sure I understand why. Invoke-Expression however, always seems to work in this context:

    PS C:\> $cmd = "cmd /c echo foo"
    PS C:\> Invoke-expression $cmd
    foo
    

提交回复
热议问题