One more thing on this. I was just re-reviewing your last comments. According to what you've stated in the comments, the original script you posted doesn't even need foreach-object, correct? Because foreach-object just adds a little processing overhead that isn't necessary since the server parameter accepts input from the pipeline. So I believe it could have been written like this:
Get-mailboxserver | Get-mailbox -resultsize unlimited | export-mailbox –subjectkeywords "Bad Message" -targetmailbox <newmailbox> -targetfolder Deleteme –deletecontent –confirm:$false
This would still allow you to break down the Get-Mailbox cmdlet into bite-sized chunks (per server) while avoiding the unnecessary use of ForEach-Object. Unless there are more unexpected things going on here that require you to use ForEach-Object.
Kirk out.
http://poshoholic.com