Thursday, April 20, 2017

Script to add an active directory user to Administrators group of a remote computer

It is needed to add users to Administrators group of Servers and Desktops. To do so, we can either access the remote computer and open Administrators group and add the users. This is time consuming and needs lot of effort. The other option is to run this script to add users to Administrators group. Save the script to file add2admins.vbs, update domain name and pass the username and computername as parameter.

Usage:

>cscript add2admins.vbs username computername


'-------- Script Start -----------
DomainName = "domainname"
UserAccount = wscript.arguments(0)
sComputer = wscript.arguments(1)
set Group = GetObject("WinNT://" + sComputer + "/Administrators,group")
group.Add "WinNT://"& DomainName &"/"& UserAccount &""
wscript.echo "Done! " & now

'--------Script End-------------

No comments:

Post a Comment

Windows Server 2016 installation

We will look at different steps to complete the basic installation of Windows Server 2016. The first step obviously is to check the Syste...