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