powershell templating powershell templating powershell powershell

powershell templating


Put your string in single-quotes so that PowerShell doesn't try to expand any variables in it e.g.:

<property name="$($settings.elementName)" value='${valueThatIsSubstitutedAtRuntime}' />

Then you can use $ExecutionContext.InvokeCommand.ExpandString(...) to expand the string at runtime e.g.:

$foo = 'bar'$str = '$foo'$ExecutionContext.InvokeCommand.ExpandString($str)


Are you sure this:

"${valueThatIsSubstitutedAtRuntime}" 

shouldn't be:

&{valueThatIsSubstitutedAtRuntime} 

That first one is the syntax for a braced variable. I think it's looking for a variable named "whatever is between the braces" (and not finding it, so it returns a null string). If it's a script block, I'd think you'd want to invoke it.