I have a hashtable like below in powershell
$children = @{'key'='value\\$child\\Parameters'}
Now consider the below:
$child = "hey"
$parent = "$child ho"
Write-Host $parent
This prints
hey ho
so basically the string $parent
is able to use the string $child
defined.
When expecting the same behavior from the value of the hashtable, this doesn't happen. For example:
$child = "hey"
$children = @{'key'='value\\$child\\Parameters'}
$children.GetEnumerator() | ForEach-Object {
$param = $_.Value
Write-Host $param
}
This prints
value\\$child\\Parameters
instead of making use of $child
and printing value\\hey\\Parameters
I thought it might be because of the type so I tried using | Out-String
and |% ToString
with $_.Value
to convert in to string but it still doesn't work.
Any way to make use of $_.Value and still have the $child value injected?
Apologies but my vocab is more java-like than powershell.