Removing Exchange Mailbox Property using PowerShell

时间:2017-10-12 10:12:37

标签: powershell exchange-server

    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 个答案:

答案 0 :(得分:1)

从DeliverToMailboxAndForward的Set-Mailbox页面。

默认值为$ false。仅当您配置转发收件人或电子邮件地址时,此参数的值才有意义。

您还需要-ForwardingAddress。

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

或者

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

谢谢,蒂姆。

答案 1 :(得分:0)

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

以上代码有效。感谢您帮助启动Synapses!

罗伊