I want to compare values in two csv files and return any entries from source2 that do NOT match entries in source1 while disregarding any duplicate entries. Below is my attempt, but it does not return all entries. What would be the best way to get this script to do what I need?
$AD = Import-CSV -Path "source1.csv"
$Student = Import-CSV -Path "source2.csv"
$AD |OuterJoin-Object $Student -on UserPrincipalName | Export-CSV -Path "Path.csv"
Source1 and Source2 csv have columns "Name", "UserPrincipalName", and "TeamDesc". I want to use those to match entries. Ideally input/output would look like this:
Source1.csv
| TeamDesc | UserPrincipalName | Name |
|:---------|:--------------------|:------------|
| Team 1 | student1@domain.com | john smith |
| Team 1 | student2@domain.com | nancy drew |
| Team 2 | student3@domain.com | harvey dent |
Source2.csv
| TeamDesc | UserPrincipalName | Name |
|:---------|:--------------------|:------------|
| Team 1 | student1@domain.com | john smith |
| Team 2 | student3@domain.com | harvey dent |
Export.csv
| TeamDesc | UserPrincipalName | Name |
|:---------|:--------------------|:-----------|
| Team 1 | student2@domain.com | nancy drew |