Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

PowerShell Function Not Working as Expected

Posted on 2013-05-22
2
Medium Priority
?
267 Views
Last Modified: 2013-05-22
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?
0
Comment
Question by:dbbishop
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 41

Accepted Solution

by:
footech earned 2000 total points
ID: 39188735
You just need to change how you pass parameters to the function.
$ROOT = GetParameterValue $CSV "ROOT"

Open in new window

0
 
LVL 15

Author Closing Comment

by:dbbishop
ID: 39188760
Thank you. That worked.
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will help you understand what HashTables are and how to use them in PowerShell.
A procedure for exporting installed hotfix details of remote computers using powershell
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question