Solved

PowerShell Function Not Working as Expected

Posted on 2013-05-22
2
259 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

In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
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…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 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

14 Experts available now in Live!

Get 1:1 Help Now