Showing posts with label Active Directory. Show all posts
Showing posts with label Active Directory. Show all posts

Thursday, April 20, 2017

Script to inventory members of Administrators group in all computers in domain

A very frequent requirement for every administrator to list members of Administrators group of all computers (servers and desktops) in the domain. The script below can be used to run to get a csv file with a list of all computers in the domain and the members of Administrators local group. The type of member (User, Computer or Group) will be provided.

The output of the script is saved in file "AdminMembers.csv" file at the same path of script. The script also uses a temporary file "c:\RunResult.tmp" to store ping results to verify if the computer is online or not. Both can be modified in the script to values of your choice.




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-------------

1

1-       INA sample review of 22 problem closure reports found that only 8 contained documented lessons learned, while the remaining 14 did ...