我正在尝试编写Powershell脚本,该脚本将用户从交换列表中隐藏起来。
我能够找到以下命令:Set-Mailbox -Identity [user id here] -HiddenFromAddressListsEnabled $true
而且它没有给我错误消息,并且当我两次运行命令时,我得到以下警告:
WARNING: The command completed successfully but no settings of '[user id here]' have been modified.
这可能意味着该命令确实有效。
但是当我转到Exchange管理控制台并打开用户配置文件时,“
hide user from exchange address lists
”复选框处于关闭状态。
可能是什么原因?
请您参考如下方法:
我将其用作每日计划任务,以从全局地址列表中隐藏在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 }