question

cbriss911-1335 avatar image
0 Votes"
cbriss911-1335 asked IanXue-MSFT answered

Adding addition custom field to CSV using Powershell.

104781-image.png


windows-server-powershell
image.png (28.5 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.