我正在寻找脚本,帮助我添加"_“在Exchange中的所有SMTP地址。
假设我们有一个用户John Doe。John有3个不同的SMTP地址:
john.doe@contoso.com
jdoe@domain.com,
john@contoso.com
我想要更改禁用交换中的所有功能(如OWA,ActiveSync等),隐藏他在GAL中的帐户,并将他的所有地址设置为:
_john.doe@contoso.com
_jdoe@domain.com,
_john@contoso.com
我可以对主SMTP执行此操作,但不能对其余SMTP执行此操作:(
现在,我尝试了这样的解决方案:
Set-Mailbox $sam -HiddenFromAddressListsEnabled $true -DomainController $dmc
Set-CasMailbox $sam -OWAEnabled $false -ActiveSyncEnabled $false -MAPIEnabled $false -PopEnabled $false -ImapEnabled $false -DomainController $dmc
mbx = Get-Mailbox $sam -DomainController $dmc | select -expand EmailAddresses | %{$_.SmtpAddress}
foreach ($M in $mbx)
{
[string]$email += "'smtp:_"+$M+"',"
} 但这对我不起作用。我是个新手,所以你能帮我吗?
发布于 2014-07-03 03:04:08
多个问题:
Set-Mailbox -EmailAddresses
$email = $(foreach ($m in $mbx) { "'smtp:_“+ $m + "'”}) -join ',‘
循环返回由每次迭代生成的字符串数组,邮箱将它们连接成逗号分隔的字符串。
-join ',' 的Set参数接受一个数组参数。因此,您只需要使用循环的返回值作为argument.
?{$_.Prefix.ToString() -eq 'smtp'}
把所有这些放在一起:
foreach ($mbx in (Get-Mailbox <whatever>)) {
$modified_addresses = $mbx.EmailAddresses `
| ?{$_.Prefix.ToString() -eq 'smtp'} `
| select -ExpandProperty EmailAddresses `
| %{"_$_"}
Set-Mailbox $mbx -EmailAddresses $modified_addresses
}https://stackoverflow.com/questions/24527358
复制相似问题