How To Powershell Import CSV And Parse Data Out Of CSV Using Comparison Operators

How To Powershell Import CSV And Parse Data Out Of CSV Using Comparison Operators

HomeOther ContentHow To Powershell Import CSV And Parse Data Out Of CSV Using Comparison Operators
ChannelPublish DateThumbnail & View CountActions
Channel Avatar Lockard2018-10-17 00:59:50 Thumbnail
15,934 Views
How To Powershell Import CSV And Parse Data Out Of CSV Using Comparison Operators.
Using the import-csv cmdlet with where-object and parse the data out of the CSV file using comparison operators:

-eq Equal
-ne Not equal
-ge Greater than or equal
-gt Greater than
-lt Less than
-le Less than or equal
-like Wildcard comparison
-notlike Wildcard comparison

Logical operators
-and Logical And

Examples:

$file= /”C://Users//Nick//Downloads//data.csv/”
$data= import-csv $file
$results= $data | where {$_.Username -eq /”Sam Blackman/”}
$results

$file= /”C://Users//Nick//Downloads//data.csv/”
$data= import-csv $file
$results= $data | where {$_.Username -like /”*Sam*/”}
$results

$file= /”C://Users//Nick//Downloads//data.csv/”
$data= import-csv $file
$results= $data | where {$_.ID -le /”5/”}
$results |ft | out-file test13.txt

$file= /”C://Users//Nick//Downloads//data.csv/”
$data= import-csv $file
$results= $data | where {($_.Location -notlike /”Seattle/”) -and ($_.Location -notlike /”Washington DC/”)}
$results

This video is brought to you by https://www.lockard.it

Please take the opportunity to connect and share this video with your friends and family if you find it useful.