-----provide ad\exchange\lync\sharepoint\crm\sc\o365 and other Microsoft product implementation and outsourcing, qq:185426445. Phone 18666943750
Step 1, the user needs are as follows: After the staff leaves, the ad account is disabled and moved to the specified 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
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/77/BB/wKiom1ZtIZfB7p-oAAC90nVRgf8856.png "title=" QQ picture 20151213154306.png "alt=" Wkiom1ztizfb7p-oaac90nvrgf8856.png "/>
Step 2, if you want to further delete the account, we execute the following command
Get-aduser-searchbase "ou=dimission,dc=yuntcloud,dc=com"-filter *| Remove-adobject-confirm: $false
Step 3, such as according to the CSV table information moved to the specified OU, and disabled, the operation is as follows:
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
}
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/77/BC/wKiom1ZtL7PQ12PrAAC_bCRO9KU272.png "title=" QQ picture 20151213164315.png "alt=" Wkiom1ztl7pq12praac_bcro9ku272.png "/>
This article is from the "Zhou Ping Microsoft Technology Exchange Platform" blog, please be sure to keep this source http://yuntcloud.blog.51cto.com/1173839/1722521
PowerShell Management Series (29) PowerShell action Mobile account to the specified OU