>There is the almighty root account in *nix and here in Windows world is the powerful and omnipotent Administrators group.Actually there can be different admin groups like domain admins,enterprise admins(ultimate account in a Microsoft Windows network) and of course the local administrator account on a standalone Windows box.
Wouldn’t it be great if there is an automatic way to find out who all are the administrators or belonging to the admin group on a Windows box? Many ways to find out like using computer management to connect to remote machine and all but it is tedious.
Scripting comes to the rescue once again here.Here is a simple but powerful script that with a slight modification can do what we want it to do.
This script is the one which gets a list of local administrators on current machine :
‘Get list of admins on machine
computername = createobject(“wscript.network”).computername
set group = getobject(“WinNT://” & computername & “/administrators,group”)
s = “”
for each account in group.members
s = s & account.name & vbcrlf
next
msgbox s
Copy paste the above code and save it as adminlist.vbs or something sensible with a .vbs extension.
Let’s just see what the script does briefly :
1.Connect to the WMI namespace of Windows machine.
2.Parse the group listed as “administrators”.
3.Output each of the values of that group in a nice message box.
If the list of users is needed instead of administrators,a modification from:
set group = getobject(“WinNT://” & computername & “/administrators,group”)
to
set group = getobject(“WinNT://” & computername & “/users,group”) is all what is needed.
Peace.