Solved

PowerShell Function Not Working as Expected

Posted on 2013-05-22
2
260 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
2 Comments
 
LVL 39

Accepted Solution

by:
footech earned 500 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

Utilizing an array to gracefully append to a list of EmailAddresses
Synchronize a new Active Directory domain with an existing Office 365 tenant
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

775 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