Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Howto use the splatting operator on a nested hashtable within a foreach-loop without a temp variable

$
0
0

Hi Guys,

consider this simple nested hashtable

$items = @{"First" = @{"Parameter1" = "Value1""Parameter2" = "Value2"
	}"Second" = @{"Parameter1" = "Value1""Parameter2" = "Value2"
	}
}

If I want to pass the values into a function using the splatting (@) operator, I have to use something like this:

foreach($item in $items.GetEnumerator())
{
	$currentItem = $item.Value
	Write-Host @currentItem
}

Do I really need a temp variable (currentItem)? I tryed something like this:

foreach($item in $items.GetEnumerator())
{
    Write-Host @item.Value # doesn't work.
    Write-Host @($item.Value) # doesn't work.
}


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>