17 lines
469 B
PowerShell
17 lines
469 B
PowerShell
# imports emails into CSV from a CSV containing DisplayName
|
|
|
|
$CSVFile = 'C:\Users\eeckert\Downloads\MS Project.csv'
|
|
|
|
$csvdata = Import-Csv $CSVFile
|
|
|
|
foreach ($item in $csvdata) {
|
|
$dname = $item.'Computer Current User Display Name'
|
|
$Filter = "DisplayName -eq '$dname'"
|
|
try {$item.Email = (Get-ADUser -Filter $Filter -Properties mail).mail}
|
|
catch {$item.email = 'lookup Failed'}
|
|
|
|
}
|
|
|
|
# $emails = $csvdata.Email
|
|
|
|
$csvdata | Export-Csv -Path $CSVFile |