Sprengdilly
Sprengdilly

Reputation: 65

Sorting a CSV File and Filtering Powershell

First what I am trying to do is Filter out and delete all of the data except the administrators in the Name0 column but I want to leave everything that is in the row of them administrators.Here is the image of how the data looks.

Import-Csv 'U:\Local Group Members.csv' | Sort-Object -Property Name0 | Export-Csv -notypeinformation U:\newcsv.csv

How do I filter out everything except the administrators which is in the Name0 column?

Upvotes: 1

Views: 322

Answers (1)

BenH
BenH

Reputation: 10044

You could filter with the Where-Object cmdlet

Import-Csv 'U:\Local Group Members.csv' |
    Where-Object {$_.Name0 -eq "administrators"} |
    Export-Csv -notypeinformation U:\newcsv.csv

Upvotes: 2

Related Questions