I'm running into a problem with a powershell script and I think it may be datatype related but am not sure. I would appreciate any suggestions for fixing this.
The following line of code when run againt my Office 365 server produces the expected output, a collection of objects
emails sent in the last 2 days that are still pending.
get-messagetrace -StartDate (get-date).AddDays(-2) -EndDate (get-date).AddDays(1) -Status "Pending"
However, the following lines of code:
$PendMessages = get-messagetrace -StartDate (get-date).AddDays(-2) -EndDate (get-date).AddDays(1) -Status "Pending" Write-Host $PendMessages
produce the following output:
Microsoft.Exchange.Management.FfoReporting.MessageTrace Microsoft.Exchange.Management.FfoReporting.MessageTrace
For reference, the object attributes of this command are:
get-messagetrace | gmTypeName: Deserialized.Microsoft.Exchange.Management.FfoReporting.MessageTrace
Name MemberType Definition
---- ---------- ----------
ToString Method string ToString(), string ToString(string format, System.IFormatProvider formatProvider)
PSComputerName NoteProperty System.String PSComputerName=pod51043psh.outlook.com
RunspaceId NoteProperty System.Guid RunspaceId=af38c0b2-665f-44b1-b00b-6d6dc7322536
EndDate Property System.DateTime {get;set;}
FromIP Property System.String {get;set;}
Index Property System.Int32 {get;set;}
MessageId Property System.String {get;set;}
MessageTraceId Property System.Guid {get;set;}
Organization Property System.String {get;set;}
Received Property System.DateTime {get;set;}
RecipientAddress Property System.String {get;set;}
SenderAddress Property System.String {get;set;}
Size Property System.Int32 {get;set;}
StartDate Property System.DateTime {get;set;}
Status Property System.String {get;set;}
Subject Property System.String {get;set;}
ToIP Property {get;set;}