'Check if a value in a list exist in a column and if not, write the non existing value to the next column

I have a csv file containing metadata exported from a pst e.g from, to, cc, bcc. I have a list i can query:

\*\*my list \*\*
Wayne, John
little, Joe

I have multiple values in each row under the "To" column.I like to process this csv file in PowerShell. If a value from my list above doesn't exist in the "To" column, I like to add the missing value to the next column

this is how it should look like

before

to notInTheList
Wayne, John; Cartwright, Hoss; little, Joe

After

to notInTheList
Wayne, John; Cartwright, Hoss; little, Joe Cartwright, Hoss
$Metadata       = import-csv "E:\\tmp\\MetaData.csv"
$myList         = import-csv "E:\\tmp\\myList.csv"

foreach($member in $myList){

    foreach($name in ($csv.sentto.split(";"))){
    
            if($name -ne $members ){
                         
            }
        }
}$name

This gives me the name but struggling with adding the outcome ($name) in the loop to the existing csv.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source