从通讯组中删除用户

从通讯组中删除用户

本文介绍了从通讯组中删除用户,而无需其他确认的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下面有可以使用的交流powershell脚本,但是我对powershell脚本了解不多,因此希望我可以在如何实现相同想法方面获得一些帮助,但不必确认将用户从脚本运行时每个组.基本上想运行脚本,删除用户并完成脚本,而无需任何其他确认.如果需要任何其他信息,请告诉我.

I have the exchange powershell script below that works, but I don't know a lot about powershell script so hoping i could get some help in how I can have this same idea work, but not have to confirm removing the user from each group as the script runs. Basically want to run the script, remove the user and be done with it without any additional confirmation needed. If any additional information is needed, please let me know.

    $user = "[email protected]"
    $groups = Get-DistributionGroup
    $DGs = $groups | where-object { ( Get-DistributionGroupMember $_ | where-object { $_.PrimarySmtpAddress -contains $user}) }

    foreach( $dg in $DGs){
        Remove-DistributionGroupMember $dg -Member $user
    }

推荐答案

浏览关于Remove-DistributionGroupMember -Confirm参数下的文档,他们说:

Looking through the documentation on Remove-DistributionGroupMember under the -Confirm parameter they say:

所以要压住提示,看起来您需要做的就是这样:

So to surpress the prompt it looks like all you need to do is this:

foreach( $dg in $DGs){
    Remove-DistributionGroupMember $dg -Member $user -Confirm:$False
}

这篇关于从通讯组中删除用户,而无需其他确认的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 19:12