Solved

PowerShell Function Not Working as Expected

Posted on 2013-05-22
2
258 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
Comment Utility
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
Comment Utility
Thank you. That worked.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Hi all.   The other day I had to change the passwords for a bunch of users on the fly. Because they were so many, I decided to do it in an automated way and I would like to share it with you all.   If you are not doing it directly in a Domain Co…
The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now