PowerShell add users to the local administrators group
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.