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"}
$msgs.count

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:
https://practical365.com/exchange-server/speed-up-multi-server-message-tracking-log-searches-with-powershell-remoting/

any assistance will be great.
LVL 23
timgreen7077Exchange EngineerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

timgreen7077Exchange EngineerAuthor 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.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
timgreen7077Exchange EngineerAuthor Commented:
See solution.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.