简体   繁体   English

Powershell从所有DL中删除所有禁用用户

[英]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.

相关问题 如何通过 Powershell 从禁用的 Active Directory 用户中删除所有组? - How do I remove all the groups from disabled Active Directory Users via Powershell? PowerShell 从特定组中删除所有用户 - PowerShell Remove all users from a specific group PowerShell:删除所有用户对目录的所有权限 - PowerShell: Remove all permissions on a directory for all users Powershell从路径中的特定文件夹中删除项目(适用于所有用户) - Powershell remove items from specific folder in path (for all users) powershell查找所有组的所有用户标志为禁用 - powershell find all users for all groups flag as disabled 使用 PowerShell 从 Azure AD 组中删除所有用户的最快方法 - Fastest way to remove all users from an Azure AD group with PowerShell PowerShell - 获取AD中所有非禁用用户的密码到期时间 - PowerShell - Get Password Expiration for all non Disabled Users in AD 从 powershell 中的多个 cmdlet 创建所有已禁用 AD 用户的 csv 文件和邮箱 Output 信息 - Create csv file of all disabled AD users with mailboxes Output information from multiple cmdlets in powershell 用于列出经理帐户被禁用的所有用户的 Powershell 脚本 - Powershell script to list all users whose manager account is disabled 从管理门户上显示的所有 Office 365 组中删除 CVS 文件中的禁用用户 - Remove Disabled users in a CVS file from all Office 365 Groups that appear on the admin portal
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM