Hello PowerShell companions. I’ve just signed up to this wonderful site after watching the PowerShell introduction by Jeffrey Snover and Jason Helmick on Microsoft Virtual Academy, who highly recommended it! I’m glad to be here!
I have written a little PowerShell script (can I call them ‘scripts’? Or should I say CMDLets?) to retrieve some simple Exchange messagetracking results. Here’s my script, which uses a csv file which only contains two columns. Column A contains a sending email address and Column B contains a recipient email address. My PowerShell script retrieves all emails sent from the sending email address from Column A to the recipient email address in Column B.
$UserList = IMPORT-CSV c:\data.csv
This foreach will loop all the rows in the above userlist
FOREACH ($User in $UserList)
{get-transportservice | get-messagetrackinglog -start “01/01/16” -sender $User.sender -recipients $User.recipient -eventid “submit” | select-object eventid, sender, timestamp, @{name=“recipients”;expression={$.recipients}},@{name=“RecipientStatus”;expression={$.recipientstatus}},messagesubject | export-csv c:\Output.csv -append }
The above works perfectly. The only issue is that in the output.csv, I would like more data, such as the TotalItemSize. When I modify the above script to include:
{get-transportservice | get-messagetrackinglog -start “01/01/16” -sender $User.sender -recipients $User.recipient -eventid “submit” | select-object eventid, sender, timestamp, @{name=“recipients”;expression={$.recipients}},@{name=“RecipientStatus”;expression={$.recipientstatus}},messagesubject, TOTALITEMSIZE | export-csv c:\Output.csv -append }
Unfortunately, the TotalItemSize output is always empty.
If anyone on this site is kind enough to let me know where I am going wrong, I would very appreciative.
Thanking you in advance,
TQ