0
    Get-Mailbox * -ResultSize Unlimited | Where {($_.DeliverToMailBoxAndForward -eq $false) `
-and ($_.forwardingsmtpaddress -eq $true)} | Set-Mailbox -DeliverToMailboxAndForward $true

Does anyone know why this code doesn't work? It Seems correct, it should select the mailboxes with forwarding on and then if delivertomailboxandforward is false, set it to true?

Thanks

2 Answers 2

1

From the Set-Mailbox page for DeliverToMailboxAndForward.

The default value is $false. The value of this parameter is meaningful only if you configure a forwarding recipient or email address.

You will also need -ForwardingAddress.

Get-Mailbox * -ResultSize Unlimited | Where {($_.DeliverToMailBoxAndForward
-eq $false) -and ($_.forwardingsmtpaddress -eq $true)} | `
Set-Mailbox -DeliverToMailboxAndForward $true -ForwardingSMTPAddress '[email protected]'

Or

Get-Mailbox * -ResultSize Unlimited | Where {($_.DeliverToMailBoxAndForward
-eq $false) -and ($_.forwardingsmtpaddress -eq $true)} | `
Set-Mailbox -DeliverToMailboxAndForward $true -ForwardingSMTPAddress $_.forwardingsmtpaddress

Thanks, Tim.

Sign up to request clarification or add additional context in comments.

7 Comments

Okay, thanks for the information there - I have a handful of mailboxes already configured for forwarding so, what if i just want to turn ON the delivertomailbox and forwarding for compliance reasons for those mailboxes, would i * the -forwarding address parameter in that command?
Yeah, sorry, the first example I didn't use your $_.forwardingsmtpaddress -eq $true before your pipe into Set-Mailbox. The second code example should use the existing forwardingsmtpaddress and just set it again.
Checking that again, you might not be able to pass $_.forwardingsmtpaddress through. You might have to store that in a variable and use it later in Set-Mailbox.
Yeah, just testing it now - i'm running a csv after to check the settings and it's not changing the boolean value of delivertomailboxandforward for users with forwarding on to force local copies to be stored.....Still no joy!
Does $_.forwardingsmtpaddress in Set-Mailbox have a value? I don't have Exchange setup in my test environment so I can't test it end to end. As a test, on one user, if you set -ForwardingAddress to a known good email address, does the boolean value change?
|
0
    Get-Mailbox * -ResultSize Unlimited | Where {($_.DeliverToMailBoxAndForward `
-eq $false) -and ($_.forwardingsmtpaddress -ne $null)} | `
Set-Mailbox -DeliverToMailboxAndForward $true -forwardingsmtpaddress $_.forwardingsmtpaddress

Above Code works. Thanks for helping fire up the Synapses on this one!

Roy

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.