$example = @"
<servers>
<server name="AAA" value="{{valA}}" />
<server name="BBB" value="{{valB}}" />
<server name="CCC" value="{{valC}}" />
</servers>
"@
$configVals= @{ "valA"='blah1'; "valB"="whatever2";}
$configVals.GetEnumerator() | % {
$key = "{{"+$_.key+"}}"
$example = $example.Replace($key,$_.value)
}
Write-Host $example
Not a blog about plumbing, or Super Mario, but in fact a series of posts about technology, IT and a few other things.
Search This Blog
Tuesday, 10 September 2019
Powershell rough and ready variable substitution
A very rough and ready way to transform a file based on an array of keys/values
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment