用于在交换地址列表中隐藏用户的 Powershell 命令

发布于 2024-12-13 07:56:16 字数 389 浏览 5 评论 0原文

我正在尝试编写将用户隐藏在交换列表中的 powershell 脚本。

我能够找到以下命令: Set-Mailbox -Identity [user id here] -HiddenFromAddressListsEnabled $true

它不会给我错误消息,当我运行该命令两次时,我收到以下警告:

警告:命令已成功完成,但“[此处的用户 ID]”的设置尚未修改。

这可能意味着该命令确实有效。

但是当我转到 Exchange 管理控制台 并打开用户配置文件时,“从 Exchange 地址列表中隐藏用户”复选框处于关闭状态。

可能是什么原因?

I'm trying to write powershell script which hides user from exchange lists.

I was able to find following command:
Set-Mailbox -Identity [user id here] -HiddenFromAddressListsEnabled $true

And it doesn't give me an error message, and when I run the command twice, I get following warning:

WARNING: The command completed successfully but no settings of '[user id here]' have been modified.

Which probably means that the command did actually work.

but when I go to Exchange Management Console, and open user profile, "hide user from exchange address lists" check box is off.

What could be the reason?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

岁吢 2024-12-20 07:56:17

我将其用作每日计划任务,以从全局地址列表中隐藏在 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 }

I use this as a daily scheduled task to hide users disabled in AD from the Global Address List

$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 }
临风闻羌笛 2024-12-20 07:56:17

您可以使用以下脚本,只需将 DOMAIN 替换为您的域名即可。执行时,它将提示您进行用户登录,然后从地址列表中隐藏该用户的帐户。

$name=Read-Host "Enter login name of user to hide"
Set-Mailbox -Identity DOMAIN\$name -HiddenFromAddressListsEnabled $true

布莱恩.

You can use the following script, just replace DOMAIN with the name of your domain. When executed it will prompt you for a userlogin then hide that user's account from the address lists.

$name=Read-Host "Enter login name of user to hide"
Set-Mailbox -Identity DOMAIN\$name -HiddenFromAddressListsEnabled $true

Brian.

很糊涂小朋友 2024-12-20 07:56:17

我遇到了完全相同的错误,但是我通过先运行 $false 然后运行 ​​$true 解决了它。

I was getting the exact same error, however I solved it by running $false first and then $true.

乱世争霸 2024-12-20 07:56:17

您必须将有效的Identity值之一(例如DNdomain\user等)传递给Set-Mailbox cmdlet。目前你没有传递任何东西。

You will have to pass one of the valid Identity values like DN, domain\user etc to the Set-Mailbox cmdlet. Currently you are not passing anything.

画中仙 2024-12-20 07:56:17

“警告:命令已成功完成,但“[此处的用户 ID]”的设置尚未修改。”

此警告意味着该设置已按照您想要的方式设置。所以它没有改变该对象的任何内容。

"WARNING: The command completed successfully but no settings of '[user id here]' have been modified."

This warning means the setting was already set like what you want it to be. So it didn't change anything for that object.

假装不在乎 2024-12-20 07:56:17

对于 Office 365 用户或混合 Exchange,请转到使用 Internet Explorer 或 Edge,转到 Exchange 管理中心,选择混合、设置,选择混合或在线交换的正确按钮。

连接:

连接-EXOPSSession

查看相关邮箱:

获取邮箱-filter {ExchangeUserAccountControl -eq 'AccountDisabled'
-and RecipientType -eq 'UserMailbox' -and RecipientTypeDetails -ne 'SharedMailbox' }

根据上述 0KB 大小的想法进行阻止:

获取邮箱-filter {ExchangeUserAccountControl -eq 'AccountDisabled'
-and RecipientTypeDetails -ne 'SharedMailbox' -and RecipientType -eq 'UserMailbox' } |设置邮箱-MaxReceiveSize 0KB
-HiddenFromAddressListsEnabled $true

For Office 365 users or Hybrid exchange, go to using Internet Explorer or Edge, go to the exchange admin center, choose hybrid, setup, chose the right button for hybrid or exchange online.

To connect:

Connect-EXOPSSession

To see the relevant mailboxes:

Get-mailbox -filter {ExchangeUserAccountControl -eq 'AccountDisabled'
-and RecipientType -eq 'UserMailbox' -and RecipientTypeDetails -ne 'SharedMailbox' }

To block based on the above idea of 0KB size:

Get-mailbox -filter {ExchangeUserAccountControl -eq 'AccountDisabled'
-and RecipientTypeDetails -ne 'SharedMailbox' -and RecipientType -eq 'UserMailbox' } | Set-Mailbox -MaxReceiveSize 0KB
-HiddenFromAddressListsEnabled $true

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文