PowerShell Function Not Working as Expected

I have the following function:
function GetParameterValue($ParmFile, $ParmName)
	$tmp = $ParmFile | where { $_.Key -eq $ParmName } | Select Value
	return $tmp.value

Open in new window

$ParmFile is created outside the function with the following code:
$CSV = import-csv .\Params.csv

Open in new window

$CSV is what is passed to the function. The call syntax is
$ROOT = GetParameterValue($CSV, "ROOT")

Open in new window

This is returning an empty string. I know I am reading the data into $CSV because prior code was replicating what I encapsulated into the function and working properly. Is there something I am missing here?
LVL 15
Who is Participating?
footechConnect With a Mentor Commented:
You just need to change how you pass parameters to the function.
$ROOT = GetParameterValue $CSV "ROOT"

Open in new window

dbbishopAuthor Commented:
Thank you. That worked.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.