将用户与ADgroup匹配,并从组中删除用户 [英] Match user with ADgroup and remove user from group

查看:92
本文介绍了将用户与ADgroup匹配,并从组中删除用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

脚本专家,

我有一项任务是从特定的ADgroup中删除特定用户。我有一个包含ADgroup的csv文件和作为该组成员的用户。

I've got a task to delete specific users from specific ADgroups. I have a csv file containing ADgroup and user that is member of this group.

A列:ADGroupName

Column A: ADGroupName

B列:用户帐户(A栏中提到的群组成员)

Column B: User account (Member of the group mentioned in Column A)

我想用PowerShell做的是导入CSV文件并读取例如单元格A2并删除单元格B2中提到的用户。除了B栏中提到的用户外,不能删除任何其他用户。

What I would like to do with powershell is to import the CSV file and read for example cell A2 and remove the user mentioned in cell B2. No other user can be removed except the user mentioned in column B.

CSV文件示例:

ADgroup1      ;          User2

ADgroup1               User2

ADGroup2               User5

ADGroup2              User5

ADGroup3             用户16

ADGroup3              User16

你能帮帮我吗?

先谢谢你。

推荐答案

这很容易与PowerShell有关。使用Import-Csv读入输入文件,并通过ForEach-Object管道处理每一行。在循环内部,使用Remove-ADGroupMember删除用户。

This is easy enough to do with PowerShell. Read in your input file with Import-Csv and pipe through ForEach-Object to process each line. Inside the loop, use Remove-ADGroupMember to remove the user.

语法链接:

http://ss64.com/ps/import-csv.html

http://ss64.com/ps/foreach-object.html

http://ss64.com/ps/remove-adgroupmember.html

如果您遇到问题,请发布您的脚本和错误,我们可以从那里开始。

If you run into problems, post your script and your errors and we can go from there.


这篇关于将用户与ADgroup匹配,并从组中删除用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆