Unable to Export Get-Message Tracking logs into .CSV ?

Hi All,

I have modified this script to take multiple inputs from trackingemail.csv to count the statistics for the external email that was delivered in the past 1 day.

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri PRDMAIL02-VM/.../ -Authentication Kerberos
Import-PSSession $Session -AllowClobber

$start = (Get-Date).AddDays(-1)
$end = (Get-Date)
$inputFile = "C:\trackingemail.csv"

Write-host "Time window between $($start.ToString("dd/MM/yyyy HH:MM")) until $($end.ToString("dd/MM/yyyy HH:MM")):"

$rxDomains = '@' + ((Get-AcceptedDomain).Name -join '|@')

$trackparams = @{
start = $start
end = $end
resultsize = 'Unlimited'
EventId = 'DELIVER'
}

foreach ($email in (Import-Csv $inputFile)) {

Write-host "Email address: $($email.email)"
$resultFile = "C:\$($email.email).CSV"

$TransportServers = Get-TransportService
$TransportServers | % {
Get-Messagetrackinglog -Server $_.Name @trackparams -Recipients $email.email |
? { $_.Sender -notmatch $rxDomains } |
Group-Object -NoElement Sender |
Sort-Object Count -Descending |
Select Name, Count |
Export-CSV $resultFile -NoTypeInformation
}
}

The content of trackingemail.csv file consist of two email address:

email
MyEmail@domain.com
MyManager@domain.com

However, when I execute it in my Power GUI console in my laptop, the result is blank 0 KB .CSV file:

MyEmail@domain.com.CSV
MyManager@domain.com.CSV

I need some help to fix the issue above.

Thanks in advance.