Link to home
Start Free TrialLog in
Avatar of Albert Widjaja
Albert WidjajaFlag for Australia

asked on

Modifying Powershell: Recipients returns System.Collections.ArrayList ?

I had this question after viewing Exchange Server 2013 Message Tracking Log PowerShell help ?.

Hi All,

Can anyone please share some tips on how to modify the below script to properly list the Recipients ?
Because it is now showing: System.Collections.ArrayList

Get-TransportService | 
	%{Write-Host $_.Name; Get-Messagetrackinglog -Server $_.Name -Resultsize Unlimited -Start "18/04/2017 1:00:00 AM" -End "19/04/2017 11:00:00 PM" | 
	Where {$_.Sender -contains "HelpDesk@domain.com" -and $_.Recipients -contains "Everyone@domain.com"} | 
	Select @{Name="Recipients";Expression={[string]::join(";", ($_.Recipients))}}, Sender, ClientIp, ClientHostname, Timestamp, EventID, Source, ServerHostname, ServerIp, MessageSubject, TotalBytes, ConnectorId } | 
	Export-Csv C:\TEMP\Email.csv -NoTypeInformation

Open in new window


and also the date time is bit confusing as well since I'm using DD/MM/YYYY format in my country.

Thanks in advance
Avatar of Aard Vark
Aard Vark
Flag of Australia image

You're outputting 2 objects for each transport service because of the Write-Host. A string ($_.name) and an object (the results). Try the following.

Get-TransportService | % {
	$ServerName = $_.Name
	Get-Messagetrackinglog -Server $_.Name -Resultsize Unlimited -Start "18/04/2017 1:00:00 AM" -End "19/04/2017 11:00:00 PM" | 
		Where {$_.Sender -contains "HelpDesk@domain.com" -and $_.Recipients -contains "Everyone@domain.com"} | @{n="Server";e={$ServerName}},
		Select @{Name="Recipients";Expression={[string]::join(";", ($_.Recipients))}}, Sender, ClientIp, ClientHostname, Timestamp, EventID, Source, ServerHostname, ServerIp, MessageSubject, TotalBytes, ConnectorId
} | Export-Csv C:\TEMP\Email.csv -NoTypeInformation

Open in new window

Avatar of Albert Widjaja

ASKER

Hi LearnCTX,

FYI, the Exchange Powershell is using remoting session:

$SessionRemoting = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://PRODMBXCAS04-VM.domain.com/PowerShell/ -Authentication Kerberos
Import-PSSession $SessionRemoting

Open in new window


Somehow, the result is still the same Recipients column is still showing System.Collections.ArrayList as the result.
ASKER CERTIFIED SOLUTION
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Dan it works flawlessly :-)