Hi all,
I have a small problem with the output.
Example - The Output is ok:
cls
$a = "_old1_"
$b = "_old2_"
$test1 = "This is a first command"
$test2 = "This is a second command"
$string_1 = @"
<!doctype html>
<html>
<head>
</head>
<body>
$test1$a $test1$($a)10
$test2$b $test2$($b)20
</body>
</html>
"@
$SearchTxt1="$a"
$ReplaceTxt1="_new1_"
$string_1=$string_1.replace($SearchTxt1, $ReplaceTxt1)
$SearchTxt2="$b"
$ReplaceTxt2="_new2_"
$string_1=$string_1.replace($SearchTxt2, $ReplaceTxt2)
write-host a: $string_1
I can read (with new1 etc…)
This is a first command_new1_ This is a first command_new1_10
This is a second command_new2_ This is a second command_new2_20
With a function option I have a output problem.
cls
$a = "_old1_"
$b = "_old2_"
$test1 = "This is a first command"
$test2 = "This is a second command"
$string_1 = @"
<!doctype html>
<html>
<head>
</head>
<body>
"@
function test
{
# All test are false-...
#$test1$a $test1$($a)10
#$test2$a $test2$($b)20
#"`$test1$($a) `$test1$$($b)10,"
#"`$test2$($a) `$test1$$($b)10,"
#$test1$a $test1$($a)10
#$test2$b $test2$($b)20
#`$test1$($a) `$test1$$($b)10,
#`$test2$($a) `$test1$$($b)10,
#
}
$Output = test | foreach {"$_`r`n"}
$string_2 = @"
</body>
</html>
"@
$SearchTxt1="$a"
$ReplaceTxt1="_new1_"
$Output=$Output.replace($SearchTxt1, $ReplaceTxt1)
$SearchTxt2="$b"
$ReplaceTxt2="_new2_"
$Output=$Output.replace($SearchTxt2, $ReplaceTxt2)
write-host a: $Output
I have a little test with Invoke-Expression - No cance.
No output with:
This is a first command_new1_ This is a first command_new1_10
This is a second command_new2_ This is a second command_new2_20
only example:
$test2_new1_ $test1}(new2)10,
What can I do?
I hope for a little help.
Thanks.
Ps.
Background Info:
I would like to use the html as a template and fill the variables with other values ​​if necessary…