Import-Csv -Path input.csv | foreach { # save current object into a local variable $currentLine = $_ # deal with columns $mail = $currentLine.Mail # test mail domain name # we add a property with the result of our test if ($mail -match "domain.com$") { $currentLine | Add-Member -MemberType NoteProperty -Name "domainCheck" -Value "valid" } else { $currentLine | Add-Member -MemberType NoteProperty -Name "domainCheck" -Value "invalid" } # return updated currentLine with new column $currentLine } | # export result line by line to CSV # -NoTypeInformation prevents metadata from being exported Export-Csv -Path preCheck.csv -NoTypeInformation