Reputation: 487
I'm using the following to import users from a csv file and output them to the console:
$(Import-csv $SelectedFile | Select -ExpandProperty EmailAddress)
This displays each EmailAddress on a separate line in the console but I want to output this to a log file too.
Using the following will do this but not a separate line for each EmailAddress like the above. Instead it just shows them on one line with no separator:
"$(Import-csv $SelectedFile | Select -ExpandProperty EmailAddress)" | Tee-Object $UserMigrationLog -Append
Is it possible to do what I ask within this one command?
Upvotes: 2
Views: 422
Reputation: 58931
You interpolate the result of Import-CSV
into a single string. Just remove the subexpression "$()"
and it will work:
Import-csv $SelectedFile | Select -ExpandProperty EmailAddress | Tee-Object $UserMigrationLog -Append
Upvotes: 3