加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

active-directory – 通过Power Shell脚本更改AD用户属性

发布时间:2020-12-15 18:35:10 所属栏目:安全 来源:网络整理
导读:在我正在工作的域中,我们创建了一个属性“regulationMatrix”.当我尝试像get-aduser USER -properties *这样的power shell命令时,只有当它的值设置为“regulationMatrix:{PIC}”时才会显示特定属性,否则它不会出现在输出中. 最近添加了该属性,现在我必须将
在我正在工作的域中,我们创建了一个属性“regulationMatrix”.当我尝试像get-aduser USER -properties *这样的power shell命令时,只有当它的值设置为“regulationMatrix:{PIC}”时才会显示特定属性,否则它不会出现在输出中.

最近添加了该属性,现在我必须将此属性从单个OU添加到1000个用户.

有人可以帮助我使用脚本或命令来修改特定OU中所有用户的属性.

谢谢.

$userlist = get-aduser -searchbase "OU=RandomOU,DC=contoso,DC=europa,DC=net" -filter * -properties regulationMatrix
foreach ( $users in $userlist ) {
    $username = $users.samaccountname
    $reg = $users.regulationmatrix
    write-host $username
    write-host $reg

set-aduser -identity $username -add @{'regulationMatrix'='PIC'}
            }

感谢Daniel,我想知道要添加什么,这非常有效.

这是单个用户的示例.使用过滤器或以其他方式获取用户列表,显式请求regulationMatrix属性,然后将整个内容传递到Set-ADUsercommand.使用-Replace或-Add修改属性.
Get-ADUser j.doe -Properties regulationMatrix | Set-ADUser -Replace @{regulationMatrix="Hurz"}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读