1

Following this guide: https://blogs.technet.microsoft.com/exchange/2015/03/03/want-more-control-over-sent-items-when-using-shared-mailboxes/

I must issue these commands in Exchange Powershell (Exchange Management Console):

set-mailbox <mailbox name> -MessageCopyForSentAsEnabled $True
set-mailbox <mailbox name> -MessageCopyForSendOnBehalfEnabled $True

However, I have a lot of shared mailboxes. I want don't want to have to issue this command 100 times. Is there a variable and/or script I can use for <mailbox name> which will let me automate this process for all shared mailboxes? (It's very important that I apply this to only shared mailboxes, and not just all mailboxes)

Daniel
  • 1,614
  • 9
  • 29
  • 47

2 Answers2

3

Use Get-Mailbox, pass the result to Set-Mailbox. Here's a oneliner

Get-Mailbox -Filter { <put your filter here> } | % { Set-Mailbox -MessageCopyForSentAsEnabled $True -MessageCopyForSendOnBehalfEnabled $True }

Or put it in a script.

$Mailboxes = Get-Mailbox -Filter { <put your filter here> }

Foreach ($Mailbox in $Mailboxes) {
    Set-Mailbox $Mailbox -MessageCopyForSentAsEnabled $True -MessageCopyForSendOnBehalfEnabled $True
}

The key is filtering the Get-Mailbox portion.

Jeter-work
  • 845
  • 4
  • 15
2

To get all the shared mailboxes in your environment, use:

Get-Mailbox -RecipientTypeDetails SharedMailbox

Running those commands against the results from this command should be trivial.

HopelessN00b
  • 53,795
  • 33
  • 135
  • 209
  • OK, between these two comments I feel like I could use this script: `$Mailboxes = Get-Mailbox -RecipientTypeDetails SharedMailbox Foreach ($Mailbox in $Mailboxes) { Set-Mailbox $Mailbox -MessageCopyForSentAsEnabled $True -MessageCopyForSendOnBehalfEnabled $True }` – Daniel Aug 25 '16 at 16:52
  • @Daniel You probably don't need to assign the Get-Mailbox to a variable, but yeah, that's one way to do it. Looks like it should work. You might want to run the command first to verify what Mailboxes you get back, before you run those Set commands. – HopelessN00b Aug 25 '16 at 17:21