Quantcast
Channel: TechNet Blogs
Viewing all articles
Browse latest Browse all 34890

PowerTip: Get Row from CSV File Based On Value

$
0
0

Summary: Use Windows PowerShell to get a row from a CSV file based on a specific value.

Hey, Scripting Guy! Question How can I use Windows PowerShell 4.0 to look up a specific row from a CSV file I imported into a variable?

Hey, Scripting Guy! Answer Use the Where method, and use a match pattern to search on a specific column and value, for example:

$topics = import-csv -Path C:\lit\Shakespeare.txt

$topics.Where({$PSItem.play -eq 'hamlet'}).topic


Viewing all articles
Browse latest Browse all 34890

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>