We would like to query our Exchange server for emails based on (for example) the Subject field. Not from a specific address or to a specific address, but rather all emails "that went through the server" and the term X appeared in the subject.
Preferably some standard way like REST / SOAP and so on with HTTPS. Thanks.
You have two options I think, at least with powershell. First and fastest is to do a messagetrace using get-transportservice | get-messagetrackinglog to see what messages have been received and sent. https://technet.microsoft.com/en-us/library/aa997573(v=exchg.160).aspx
Other would be to search every mailbox for messages conforming to a pre-set filter. You could use get-mailbox | search-mailbox for that. https://technet.microsoft.com/en-us/library/dd298173(v=exchg.160).aspx