步骤1、用户需求如下:人员离职后,将AD账户禁用并挪动到指定的OU

get-aduser -SearchBase "ou=test,dc=yuntcloud,dc=com" -filter *|Move-ADObject -TargetPath "ou=dimission,dc=yuntcloud,dc=com"

get-aduser -SearchBase "ou=dimission,dc=yuntcloud,dc=com" -filter *|disable-ADAccount

Powershell管理系列(二十九)PowerShell操作之移动账户到指定OU

步骤2、如需进一步删除账户,我们执行如下的命令

get-aduser -SearchBase "ou=dimission,dc=yuntcloud,dc=com" -filter *|Remove-ADObject -Confirm:$false

步骤3、如根据csv表里的信息挪动到指定OU,并禁用,操作如下:

import-csv -path c:\userinfo.csv|% `

{

$a=get-aduser -identity $_.samaccountname |% {$_.DistinguishedName}

Move-ADObject $a -TargetPath "ou=dimission,dc=yuntcloud,dc=com"

get-aduser -identity $_.samaccountname|Disable-ADAccount 

}

Powershell管理系列(二十九)PowerShell操作之移动账户到指定OU




本文转自 zhou_ping 51CTO博客,原文链接:http://blog.51cto.com/yuntcloud/1722521,如需转载请自行联系原作者


相关文章:

  • 2021-10-18
  • 2021-03-31
  • 2021-06-04
  • 2021-07-12
  • 2021-05-26
  • 2021-06-06
  • 2021-10-08
  • 2021-12-03
猜你喜欢
  • 2021-12-09
  • 2022-01-02
  • 2021-06-06
  • 2021-09-10
  • 2021-04-13
  • 2021-04-14
  • 2021-09-05
相关资源
相似解决方案