Vov*_*cev 8 powershell exchange-server exchange-server-2007
我正在尝试编写powershell脚本,将用户从交换列表中隐藏起来.
我能够找到以下命令:
Set-Mailbox -Identity [user id here] -HiddenFromAddressListsEnabled $true
它没有给我一个错误信息,当我运行命令两次时,我得到以下警告:
警告:命令已成功完成,但未修改"[user id here]"的设置.
这可能意味着该命令确实有效.
但是当我转到Exchange管理控制台并打开用户配置文件时," hide user from exchange address lists"复选框已关闭.
可能是什么原因?
小智 6
我将其用作日常计划任务,以隐藏全局地址列表中AD中禁用的用户
$mailboxes = get-user | where {$_.UserAccountControl -like '*AccountDisabled*' -and $_.RecipientType -eq 'UserMailbox' } | get-mailbox | where {$_.HiddenFromAddressListsEnabled -eq $false}
foreach ($mailbox in $mailboxes) { Set-Mailbox -HiddenFromAddressListsEnabled $true -Identity $mailbox }
Run Code Online (Sandbox Code Playgroud)