PowerShell Management Series (29) PowerShell action Mobile account to the specified OU

Source: Internet
Author: User
Tags samaccountname

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.