8,330 questions
Hi,
Please use the Ctrl-K tool to post the code. To add properties you can use the Add-Member cmdlet.
Import-Csv -Path $file | ForEach-Object{
$dn = $_.User
$ADEndDate = (Get-ADUser -Filter "DisplayName -like '*$dn*'" -Properties AccountExpirationDate).AccountExpirationDate
$_ | Add-Member -NotePropertyName "ADEndDate" -NotePropertyValue $ADEndDate -PassThru
} | Export-Csv -Path $outputfile
Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.