Reputation: 3428
I've asked this question on the SharePoint StackExchange w/ no luck
I have a CSV file with one column, SharePoint Site URLs, many of which are duplicates
Column Title
Site C URL
Site A URL
Site B URL
Site C URL
Site C URL
Site A URL
How can I retrieve the rows so the I only have unique sites:
Site A URL
Site B URL
Site C URL
I've tried:
$CSVLocation = 'C:\data\data.csv'
$siteURLs = Import-CSV -Path $CSVLocation
$siteURLs | Group-Object -Property 'Column Title' | Select-Object -Unique
Upvotes: 1
Views: 1543
Reputation: 25001
You can approach this problem several ways. One simple way is to use Sort-Object
provided you only have the one column.
$siteURLs | Sort-Object 'Column Title' -Unique
You can also use Group-Object
. Group-Object
by default outputs three properties: Count
, Name
, Group
. Since you are grouping by Column Title
, those values will appear under Name
. So if you only want to see that data, you need to select Name
.
$siteURLs | Group-Object -Property 'Column Title' | Select-Object Name
Upvotes: 3