首页 > 移动平台 > 详细

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

时间:2015-12-13 18:54:19      阅读:290      评论:0      收藏:0      [点我收藏+]

-----提供AD\Exchange\Lync\Sharepoint\CRM\SC\O365等微软产品实施及外包,QQ:185426445.电话18666943750

步骤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

技术分享

步骤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 

}

技术分享





本文出自 “周平的微软技术交流平台” 博客,请务必保留此出处http://yuntcloud.blog.51cto.com/1173839/1722521

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

原文:http://yuntcloud.blog.51cto.com/1173839/1722521

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!