0

I have a csv file which looks like below

Name
Jonh
Jimmy
Sunny
Dany

So to get compare the list of names in CSV file with another name i used the below command

$csv = $csv | where {$_.Name -ceq "Jimmy"}

I am getting output as below

Name
------
Jimmy

can I have just just have the output as

Jimmy 

Instead of

Name
-------
Jimmy

EDIT: Formatting

1

2 Answers 2

2

You should use:

$csv = $csv | where {$_.Name -ceq "Jimmy"} | Select-Object -ExpandProperty Name
Sign up to request clarification or add additional context in comments.

1 Comment

This will work even in older powershell versions - so could be useful for compatibility.
1

I believe in later versions of powershell you can simply call a property name from the results, like so:

$csv = ($csv | where {$_.Name -ceq "Jimmy"}).Name

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.