Powershell で列が CSV と部分一致または完全一致した場合に行を返す

Powershell で列が CSV と部分一致または完全一致した場合に行を返す

基本的には、文字列を検索し、完全一致または部分一致を CSV 形式で返します。

$Shoes次のようなオブジェクトがあるとします。

"Brand","Style","Color","Price"
"Reebok","Basketball","Red/Black","$50"
"Vans","Slip-On","White/Black","$60"
"Vans","Old Skool","Red/White","$60"
"Nike","Sneakers","Red","$50"
"Adidas","Sneakers","Blue","$55"

読みやすくするために、表としてフォーマットすると次のようになります。

Brand       Style       Color       Price
-----       -----       -----       -----
Reebok      Basketball  Red/Black   $50
Vans        Slip-On     White/Black $60
Vans        Old Skool   Red/White   $60
Nike        Sneakers    Red         $50
Adidas      Sneakers    Blue        $55

入力すると$Shoes -like '*Red*'次の結果が返されます:

@{Brand=Reebok; Style=Basketball; Color=Red/Black; Price=$50}
@{Brand=Vans; Style=Old Skool; Color=Red/White; Price=$60}
@{Brand=Nike; Style=Sneakers; Color=Red; Price=$50}

しかし、私が求めている出力は次のとおりです。

Brand       Style       Color       Price
-----       -----       -----       -----
Reebok      Basketball  Red/Black   $50
Vans        Old Skool   Red/White   $60
Nike        Sneakers    Red         $50

ここで何が間違っているのでしょうか?

答え1

試したときに -match のフォーマットを間違っていたようですが、簡単な解決策であることがわかりました...

それは単純に$Shoes -match 'Red'

関連情報