[英]Powershell to remove all Disabled-users from all DL's
I have the same question as this person: Remove all ex-employees from ALL distribution groups 我对此人有一个相同的问题: 从所有通讯组中删除所有前雇员
There are quite a few disabled users who left the company and need to be removed from all DLs. 有很多残疾用户离开了公司,需要从所有DL中删除。
Disabled users are locatedin: uk.domain.int/USR/Disabled Users
禁用的用户位于: uk.domain.int/USR/Disabled Users
DL's are located in: uk.domain.int/USR/Distribution Lists
DL位于: uk.domain.int/USR/Distribution Lists
There is the Powerscript provided by @Raymund and I am not quite certain about the LDAP bit. @Raymund提供了Powerscript,我不太确定LDAP位。
Would it be this in my case cos' I am not sure: 就我而言,这是因为我不确定:
LDAP://OU=Disabled Users,OU=USR,DC=uk,DC=Domain,DC=int"
Just need to make sure that the PS script does not run on any other domain apart from the one uk.domain.int and targets disabled users only. 只需要确保PS脚本除了一个uk.domain.int之外就不在其他任何域上运行,并且仅针对禁用的用户。
Please advise 请指教
ps: Powershell version: Major: 2 | ps:Powershell版本:专业:2 | Minor: 0 | 次要:0 | Build -1 | 版本-1 | Revision -1 修订-1
This LDAP Filter LDAP://OU=Disabled Users,OU=USR,DC=uk,DC=Domain,DC=int"
will look into UK subdomain, USR OU , Disabled Users OU. 此LDAP过滤器LDAP://OU=Disabled Users,OU=USR,DC=uk,DC=Domain,DC=int"
将查看UK子域USR OU,残疾用户OU。
Although provided script commands will do the job I rather use exchange management shell commands
+ active directory
powershell module commands for this purpose. 尽管提供的脚本命令可以完成此任务,但我宁愿为此使用exchange management shell commands
+ active directory
powershell模块命令。 This is just to give you some Ideas to write your own script via the right tools. 这只是为了给您一些想法,以便通过正确的工具编写自己的脚本。
import-module activedirectory
$session = new-pssession -configurationname microsoft.exchange -connectionuri "http://yourcasserver.yourdomian.com/powershell/" -authentication kerberos -credential (get-credential)
import-pssession $session
$users = get-aduser -filter * -searchbase "OU=Disabled Users,OU=USR,DC=uk,DC=Domain,DC=int"
get-distributiongroup
Another advantage of using Powershell commands is you can make sure of effect of each command in script by running int against a test user and a test DistributionGroup. 使用Powershell命令的另一个优点是,可以通过对测试用户和测试DistributionGroup运行int来确保脚本中每个命令的效果。
It's wise to test your scripts in lab environment
first. 首先在lab environment
测试脚本是明智的。 Specially when your dealing with exchange in an Enterprise. 特别是当您处理企业中的交换时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.