删除除一个以外的所有SMTP地址

时间:2012-05-31 08:26:21

标签: powershell exchange-server

我的Exchange 2010用户拥有多个smtp地址,我想删除除了其中两个以外的所有地址。尝试以下没有运气:

get-mailbox test_2 | foreach { $a = $_.emailaddresses; $b = $_.emailaddresses; foreach($e in $a) { if (($e.tostring() -match "donotdelete") -and ($e.tostring() -notmatch "donotdelete2")) { $b -= $e; } } ; $_ | set-mailbox -emailaddresses $b }

我做错了什么?

1 个答案:

答案 0 :(得分:0)

试试这个:

$mbx = get-mailbox test_2 
$emailAddresses = $mbx.emailaddresses | where { "put your your filter code here  }
set-mailbox $mbx -emailaddresses $emailAddresses