troubleshooting Question

Run multiple Powershell commands after each other

Avatar of gnoble1979
gnoble1979 asked on
Powershell
6 Comments2 Solutions1280 ViewsLast Modified:
Hi

I want toGet-mailbox -identity "User1" | Export-Mailbox -IncludeFolders "\Sent Items" -SubjectKeywords "Joke666" -StartDate "05/11/2011" -RecipientKeywords john.doe@domain.com -pathtoPST c:\user1.pst

Get-mailbox -identity "User2" | Export-Mailbox -IncludeFolders "\Sent Items" -SubjectKeywords "Joke666" -StartDate "05/11/2011" -RecipientKeywords john.doe@domain.com -pathtoPST c:\user2.pst

And so on up until User80. Rather than me sitting at the keyboard doing one, waiting for it to complete, then another, is there a way to compile these so I can place them in an Excel file (for example) and just run them as one batch in Powershell?

Secondly, instead of the above, is there way a to run the following:

Get-content c:\userlist | Get-mailbox | Export-Mailbox -IncludeFolders "\Sent Items" -SubjectKeywords "Joke666" -StartDate "05/11/2011" -RecipientKeywords john.doe@domain.com -pathtoPST c:\<username>.pst

ASKER CERTIFIED SOLUTION
soostibi

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros