Get the App
SLTechnology News&Howtos  ›  Servers  › 

PowerShell add users to the local administrators group

Shulou Source: shulou.com Published: 2022-06-02 10:47:49 10月04日 Update

Well, this is a rounding up article, but maybe some people won't, so I decided to write, hey.

There are many ways to add an administrator to a computer remotely: such as group policy, such as computer management tools

What I'm going to say this time is to use PowerShell, for example, which is actually very simple.

# declare functions and accept User and Computer parameters

Function Add-LocalAdmin ($User,$Computer)

{

([ADSI] "WinNT://$Computer/Administrators,group") .Add ("WinNT://Contoso/$User")

}

So we can reuse it, such as Add-LocalAdmin-User zhangsan-Computer Client01.

In this way, we will save a little bit of trouble. if there are a large number of users to add, the efficiency will be even higher.

Tags: Management users administrators functions parameters mass that is tools efficiency articles methods machines policies management tools that is computers or this is trouble. Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Docker Shulou Information Xiaomi Shulou Tech Info