Powershell add and delete users to a group

Source: Internet
Author: User

Easy to forget:


Today, we need to add all users under an ou to a security group and read the powershell command a little. The method is as follows:


650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/42/7C/wKiom1PYKunzPnotAAAPtHOjqnk135.png "Title =" Capture. PNG "alt =" wkiom1pykunzpnotaaapthojqnk135.png "/>

First, search for all users under an ou through get-aduser, and then add all user accounts (samaccounts) to the specified group through the pipeline.


Similarly, you can remove all users under an ou from the specified group. Because the remove command usually prompts, I added a-confirm: $ false to cancel the confirmation prompt.


650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/42/7C/wKioL1PYLe6BjagOAAANoJX9qro803.png "Title =" SS. PNG "alt =" wkiol1pyle6bjaroaaanojx9qro803.png "/>


Simple command, but very effective.

This article from the "Mapo tofu" blog, please be sure to keep this source http://beanxyz.blog.51cto.com/5570417/1532565

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.