Search code examples
powershelleval

powershell: how to evaluate a string


My file a.txt contains:

delete from test_$suffix

My PowerShell is:

$a = get-content a.txt
$suffix = "tableA"

How would I manipulate $a to obtain the string delete from test_tableA ?


Solution

  • $a=get-content a.txt
    $suffix="tableA"
    
    $ExecutionContext.InvokeCommand.ExpandString($a)