• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 38
  • Last Modified:

REMOTE Powershell for Exchange Invoke-Command

I will be connecting to Exchange via powershell remoting  because i read the searches are alot faster. Once I connect I want to run the following commands:

$msgs = Get-TransportServer | Get-MessageTrackingLog -ResultSize Unlimited -Start "2/07/2018 00:00:00" -End "3/07/2018 23:59:59"} | where{$_.sender -like "*@externaldomain.com"}

This will give me the message count for all emails that came into the org from a specific external domain.  Since i will be running this from remote powershell instead of the exchange management shell it seems that i need to run the "invoke-command" cmdlet. How should I run that cmdlet with the cmdlets above, or is it even needed. The get-transportserver will get all the transport servers in the org which is about 8 and it includes exchange 2010 and 2016 servers. Let me know if the invoke-command is needed for increased search speed or just remote powershell alone is enough to increase the speed. I have been looking at the article:

any assistance will be great.
  • 2
1 Solution
timgreen7077Author Commented:
I got this now resolved. To invoke the command syntax is as follows:

$msgs = Get-TransportServer | Invoke-Command {Get-MessageTrackingLog -ResultSize Unlimited -Start "2/07/2018 12:00:00 AM" -End "3/07/2018 11:59:00 PM" -EventID "DELIVER" | where{$_.sender -like "*@externaldomain.com"}}

The search is really fast also. Notice the location of the brackets, and allowed the cmdlets to work correctly.
timgreen7077Author Commented:
See solution.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now