0

I have two differents CSV: File1 : ActiveDirectory user Output with this Properties: Description,displayName,mail File2 : Normal CSV with the same Properties: Description,displayName,mail

The have different amount of Users, not everyone has a E-Mail. And i have to infill the E-Mail from file2 in file1 an output the the users with the infilled email.

Can you help me?

  • 3
    Great, the task seems clear. Now please show us what you have already tried yourself. Explain what problems you encountered and if you received error messages, show these too so we can help you with your code. – Theo Nov 19 '20 at 09:49
  • In case you looking for a readymade solution, you might try this [`Join-Object`](https://www.powershellgallery.com/packages/Join) cmdlet (see also: [In Powershell, what's the best way to join two tables into one?](https://stackoverflow.com/a/45483110/1701026)): `Import-Csv .\file1.csv | Update-Object (Import-Csv .\file2.csv) -On displayName` – iRon Nov 19 '20 at 18:24
  • `Import-Module "ActiveDirectory" $OU = "myADOuPath" $AdExportFile = "myPath\AdExportFile.csv" $CompareFile = "myPath\CompareFile.csv" $ResultFile = "myPath\ResultFile.csv" get-aduser -SearchBase $OU -filter * -properties * | where {!$_.emailaddress} | select-object displayName, Description | export-csv $AdExportFile` This is my Coade at the moment but i deleted the compare section, because it didnt work ^^ – tosmile01 Nov 23 '20 at 07:09
  • Uuuf.. ok i don't kow how to post code in here :D Sorry if it looks like sh*t. But anyway thanks – tosmile01 Nov 23 '20 at 07:12
  • To insert formatted code in the question, have a look [here](https://meta.stackexchange.com/questions/22186/how-do-i-format-my-code-blocks/22189#22189). Your question is about two csv files where file1 needs to be updated using the data from file2. The code in your comment however gets all the info fresh from AD.. So, what exactly do you want to do? I'd say, get info from AD and forget about the two csv files which apparently are incomplete anyway. – Theo Nov 28 '20 at 20:55

0 Answers0