I am trying to filter the data contains in excel. but it showing error.
Import-Csv -Path "D:\Excel\Data\List.csv" -Header "EventID", "TimeCreated", "Computer", "TargetUserName", "SubjectUserName", "HOSTName", "Filename" |
Where-Object {[INT]$_.TargetUserName -eq 122388} |
Select-Object "EventID", "TimeCreated", "Computer", "TargetUserName", "SubjectUserName", "HOSTName", "Filename" |
Export-Csv "D:\Excel\test.csv" -NoTypeInformation
CodePudding user response:
It's likely getting read in as a string instead of an integer. Do an equality test against a string instead.
Try replace Where-Object {[INT]$_.TargetUserName -eq 122388}
with Where-Object {$_.TargetUserName -eq "122388"}