Expanding variables in file contents

前端 未结 3 2079
闹比i
闹比i 2020-12-09 15:05

I have a file template.txt which contains the following:

Hello ${something}

I would like to create a PowerShell script that re

3条回答
  •  情话喂你
    2020-12-09 15:51

    I've found this solution:

    $something = "World"
    $template = Get-Content template.txt
    $expanded = Invoke-Expression "`"$template`""
    $expanded
    

提交回复
热议问题