Hi @Franthesco De Paula Ferrari
Greetings!
Thank you for posting your query on Q&A.
I understand that you are trying to Import a csv file with the some of existing user details in the tenant and you want to export the listed user details with the required filed such as Mail and Name, Email, Display name.
To achieve your ask you can use the below power shell script.
$users=@()
$csvFile = Import-Csv -Path "C:\Import\sampleuser_2.csv"
foreach ($row in $csvFile) {
$displayName = $row.displayName
$users += Get-AzureADUser -Filter "DisplayName eq '$displayName'" | Select-Object UserPrincipalName,ObjectId,Mail
}
$users | Export-Csv -Path "C:\Export\sampleuser_2.csv" -NoTypeInformation
In the above script it will extract the UserPrinciplName, Mail, ObjectId from the given input.
If you want to import more fields you can make the changes by adding the name of the fields in the 5th line of the above script.
I hope this answer helps! please Feel free to ask any questions you may have.
Thanks,
Akhilesh.
Please "Accept the answer" if the information helped you. This will help us and others in the community as well.