0

I have to compare emails from PST against living Mailbox. For that i wrote an entire script-program, using Outlook.Application and Namespace MAPI, to get objects and access their attributes.

To run all of it, it's takes time. Playing with object and folders-object via scripting language, will not be as fast as it can be in other language. fore that i tried to use Build-in Method, in manner to expedite the process. I thought that i can create index of mails from both sides. each item in the index includes 4 attributes - senton, subject, body, messageclass. than, compare Items from PST Index against MailBox Index will be faster then comparing the entire objects. But that also can take too long. sometimes 2 days.

While Compare-Object can compare both indexes in few minutes, the result aren't reliable. i can get 2 items which their comparison parameters are completely identical, but Compare-object recognize it as different, somehow. if i compare by myself those attribute like show hereby:

$a.senton -eq $b.senton

True

And so on with the other attributes.

My question is, how can i make Compare-Object to be accurate and produce the most true result, so i can relay on it without fear of losing data.

Regards Yosi.

=================

OK than. So, let's see that i have the following code:

$a = import-csv -path c:\...file.a
$b = import-csv - path c:\...file.b

 `Compare-Object -ReferenceObject $a -DifferenceObject $b -Property senton, subject, messageclass`   

After the attributes of COMObjects have been exported and later imported back from CSV, it's all strings. in this case, compare string against the same string shouldn't work?

YosiCohen
  • 1
  • 1
  • 1
    Can you show the full `Compare-Object` command you use? Which properties are you comparing? – Mathias R. Jessen Feb 15 '22 at 13:10
  • 3
    `Compare-Object` relies on the objects actually implementing compare methods, or, if they do not, it will fall back on comparing the results of `.ToString()`. Unfortunately this means that for the vast majority of cases, the end result is useless if you just feed it objects -- in particular, no COM object will implement comparability natively, nor do custom PSObjects. What does work is explicitly specifying the properties to compare on using the `-Property` switch (assuming those properties themselves are comparable, of course). – Jeroen Mostert Feb 15 '22 at 13:15
  • 4
    Also the order of the 2 lists won't matter without -syncwindow 0. And you need to specify the properties to compare. – js2010 Feb 15 '22 at 13:33
  • You can always [edit] your question to supply more details, and you should do so especially if you're adding code, since comments are a poor medium for that. – Jeroen Mostert Feb 15 '22 at 14:11
  • You need to at least put the first property to compare against directly after the `-Property` parameter name (wel.. it does need a space between of course) and is `messegeclass` a typo and shouldn't that be `messageclass` ?? – Theo Feb 15 '22 at 14:55
  • Don't mind the order. in the original code it's written properly without misspells. Here the text editor braking line without my permission. – YosiCohen Feb 15 '22 at 15:07
  • Then show us _the original code where it's written properly_. Leaving mistakes in the question is asking for people to reflect on those. – Theo Feb 15 '22 at 15:17
  • Why not share a minimal example of fileA and fileB and your expected result to your question, it might be easier to provide an answer – Santiago Squarzon Feb 15 '22 at 18:51

0 Answers0