PowerShell add user to local Administrators group

Source: Internet
Author: User
Well, this is a dine article, but maybe someone won't, so I decided to write, hey


There are many ways to add administrators to a computer remotely: such as Group Policy, such as Computer Management tools

This time to say is to use PowerShell again, in fact, very simple

#声明函数, and accept the user and computer parameters

Functionadd-localadmin ($User, $Computer)

{

([ADSI] "winnt://$Computer/administrators,group"). ADD ("winnt://contoso/$User")

}


So we can use it again, like Add-localadmin-user zhangsan-computer Client01

So we save a little bit of trouble, if there is a large number of users to add, this efficiency improvement is higher ~ ~



PowerShell add user to local Administrators group

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.