csv - Powershell looking through all columns searching for a keyword -


using powershell, lets have csv file contains

fname,lname,id,etc.. 

is there way use where-object through of columns instead of one.

for example, instead of doing:

import-csv location |where-object {$_.fname -eq "hi"} 

next line:

import-csv location |where-object {$_.lname -eq "hi"} , on. 

it like:

import-csv location |where-object {any -eq "hi"} 

yes, iterate on $_.psobject.properties inspect every column , return $true if 1 of them matches:

import-csv document.csv |where-object {     foreach($p in ($_.psobject.properties |? {$_.membertype -eq 'noteproperty'})) {         if($p.value -match "hi"){ $true }     } } 

Popular posts from this blog