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

user3012708
  • 793
  • 1
  • 11
  • 33
  • Possible duplicate of [Select the values of one property on all objects of an array in PowerShell](https://stackoverflow.com/questions/5176815/select-the-values-of-one-property-on-all-objects-of-an-array-in-powershell) – iRon Oct 18 '19 at 14:25

2 Answers2

2

You should use:

$csv = $csv | where {$_.Name -ceq "Jimmy"} | Select-Object -ExpandProperty Name
Alfredo Liardo
  • 115
  • 2
  • 2
  • 10
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
user3012708
  • 793
  • 1
  • 11
  • 33