I’ve got a script which exports a CSV of the mailboxes receiving the highest number of external mail.
The CSV only contains the number of external emails in the last day and the receiving e-mailaddress.
$Days = 7
$CSV = "$env:TEMP\$(Get-Date -Format "yyyyMMdd")-$($Days)-AddressList.csv"
$rAdds = $messageList | Select-Object -ExpandProperty RecipientAddress | Where-Object -FilterScript {$_ -like '*@[MAIL-SUFFIX]'}
$rAdds | Group-Object | Sort-Object -Property Count -Descending | Where-Object -FilterScript {$_.Count -gt 10 } | Select-Object -Property Count, Name | Export-Csv -Path $CSV -NoTypeInformation -Encoding utf8 -Delimiter ';'
I’ve been asked to add a Date or DateTime column to the CSV for easier handling in PowerBI and I’m honestly embarrassed that I’m not sure exactly how to go about that. Basically they want Get-Date -Format yyyy-MMdd
added to each entry.
I’ve found a number of topics about adding a column to an existing CSV - and I guess I could reimport the CSV and modify it before exporting it again. I really think there should be an easier way of just adding it before the export.