I am reading a text file. I need to expand the variable in the string. I do not want to run the whole line. It is like I am getting a '' Literal string. I do not what kind of string has "".
make the a text file called C:\temp\testfile.txt.
add the line
Thisbrokenit test1 $OnlyExpandThisValue
run the code
$OnlyExpandThisValue = "It WORKS!"
$testit = Get-Content C:\temp\testfile.txt
Invoke-Expression $testit
$($testit)
I am needing to get the result below.
Thisbrokeit test1 It WORKS!