Expand string Variable stored via Single Quote in Powershell

前端 未结 2 457
挽巷
挽巷 2020-12-11 22:08

I have a scenario where I need to construct a powershell path as $RemotePath = \'$($env:USERPROFILE)\\Desktop\\Shell.lnk\'. This variable gets passed to a remot

相关标签:
2条回答
  • 2020-12-11 22:53

    Expand the string on the remote side:

    $ExecutionContext.InvokeCommand.ExpandString($RemotePath)
    
    0 讨论(0)
  • 2020-12-11 22:56

    By using a double quotes. PowerShell won't expand variables inside single-quoted strings.

    0 讨论(0)
提交回复
热议问题