We have a Group which is both a Security Group and Distribution Group (emails) called "MyCompany Staff".
(For example Acme Staff)
This we add to the local Power Users Group. In means that on installs outside of GPO you will need to Run As.. and Administrator, but this isn't too much a pain to make sure your general users don't inadvertantly install something malicious while on the web.
I strongly recommend you DON'T add Domain Users to either group, especially Administrators. The reason is that Domain Users is the default group for all created accounts, and later down the line you might create a Temp account for a temp worker, and they will have Admin access to every machine before you definitely know you want this.
You could add it tio Power Users, but better is to create a separate Security Group and add all new users to this group. You can add users automatically using a script I wrote:
Code:
'==========================================================================
'
' NAME: AddUserToGroup
'
' AUTHOR: Russ Clements , Clements IT
' DATE : 20/01/2004
'
' COMMENT: Adds a specified user to the specified
' computer\domain Group.
'
'==========================================================================
Option Explicit
Dim sComputer, sGroup, sUser, sDomain
Dim WSHSHell, oGroup, oUser
Set WSHShell = CreateObject("WScript.Shell")
' Request the group name
sDomain = InputBox("Please enter a Domain Name:" + vbCrLf + _
"(default is the MyDomain domain)", _ ' change to your default domain
"AddUserToGroup Input Domain Name", _
"mydomain", 100, 100) ' change to your default domain
If sDomain = "" Then
sDomain = "mydomain" 'change to your default domain
End If
' Request the Domain or single-Computer name
sComputer = InputBox("Please enter a computer name:" + vbCrLf + _
"(default is this computer)", _
"AddUserToGroup Input Computer Name", _
".", 100, 100)
If sComputer = "" Then
sComputer = "."
End If
' Request the group name
sGroup = InputBox("Please enter a Group name:" + vbCrLf + _
"(default is the Power Users group)", _
"AddUserToGroup Input Group Name", _
"Power Users", 100, 100)
If sGroup = "" Then
sGroup = "Power Users"
End If
' Request the group name
sUser = InputBox("Please enter a Username:" + vbCrLf + _
"(default is your username)", _
"AddUserToGroup Input Username", _
LCase(WSHShell.ExpandEnvironmentStrings("%username%")), 100, 100)
If sUser = "" Then
sUser = LCase(WSHShell.ExpandEnvironmentStrings("%username%"))
End If
' Build the ADSI query and retrieve the group object
Set oGroup = GetObject("WinNT://" & sComputer & "/" & sGroup & ",group")
Set oUser = GetObject("WinNT://" & sDomain & "/" & sUser & ",user")
On Error Resume Next
'WScript.Echo "oGroup.Name: " & oGroup.Name
'WScript.Echo "oUser.Name: " & oUser.Name
'WScript.Echo "oUser.ADsPath: " & oUser.ADsPath
' Remove User from Group.
oGroup.Add(oUser.ADsPath)
oGroup.Setinfo
If Err.Number <> vbEmpty Then
WScript.Echo "Error: Add failed."
Else
WScript.Echo "Success: User Added to group."
End If
Set oUser = Nothing
Set oGroup = Nothing
If you feel up to it, it woldn't be hard to change it to read a text file of all your users.
To remove users, the following script works:
Code:
'==========================================================================
'
' NAME: RemoveUserFromGroup
'
' AUTHOR: Will Clements , Clements IT
' DATE : 20/01/2004
'
' COMMENT: Adds a specified user to the specified
' computer\domain Group.
'
'==========================================================================
Option Explicit
Dim sComputer, sGroup, sUser, sDomain
Dim oGroup, oUser
' Request the group name
sDomain = InputBox("Please enter a Domain Name:" + vbCrLf + _
"(default is the MyDomian domain)", _ ' change to your default domain
"RemoveUser Input Domain Name", _
"mydomain", 100, 100) ' change to your default domain
If sDomain = "" Then
sDomain = "mydomain" ' change to your default domain
End If
' Request the Domain or single-Computer name
sComputer = InputBox("Please enter a computer name:" + vbCrLf + _
"(default is this computer)", _
"RemoveUser Input Computer Name", _
".", 100, 100)
If sComputer = "" Then
sComputer = "."
End If
' Request the group name
sGroup = InputBox("Please enter a Group name:" + vbCrLf + _
"(default is the Administrators group)", _
"RemoveUser Input Group Name", _
"Administrators", 100, 100)
If sGroup = "" Then
sGroup = "Administrators"
End If
' Request the group name
sUser = InputBox("Please enter a Username:" + vbCrLf + _
"(default is the Guest username)", _
"RemoveUser Input Username", _
"guest", 100, 100)
If sUser = "" Then
sUser = "guest"
End If
' Build the ADSI query and retrieve the group object
Set oGroup = GetObject("WinNT://" & sComputer & "/" & sGroup & ",group")
If InStr(sUser, "S-1") = 1 Then
Set oUser = GetObject("WinNT://" & sUser)
Else
Set oUser = GetObject("WinNT://" & sDomain & "/" & sUser & ",user")
End If
On Error Resume Next
'WScript.Echo "oGroup.Name: " & oGroup.Name
'WScript.Echo "oUser.Name: " & oUser.Name
'WScript.Echo "oUser.ADsPath: " & oUser.ADsPath
' Remove User from Group.
oGroup.Remove(oUser.ADsPath)
oGroup.Setinfo
If Err.Number <> vbEmpty Then
WScript.Echo "Error: Remove failed."
Else
WScript.Echo "Success: User removed from group."
End If
Set oUser = Nothing
Set oGroup = Nothing
And then finally, if yopu want to check users in a group on a domain or local machine, the following script is useful:
Code:
'==========================================================================
'
' NAME: ListGroupMembers
'
' AUTHOR: Russ Clements , Clements IT
' DATE : 20/01/2004
'
' COMMENT: Enumerate members of a particular group. Set here For
' Administrators group as default, but if comments removed
' from inputbox, user can stipulate different groups at will.
'
'==========================================================================
Dim strCompOrDom, strGroup, strMembers
Dim objWMIService, objFSO, objFile
Set WSHShell = WScript.CreateObject("WScript.Shell")
' Request the Domain or single-Computer name
strCompOrDom = InputBox("Please enter a computer or Domain name", _
"ListGroupMembers Input Computer or Domain Name", _
".", 100, 100)
If strCompOrDom = "" Then
strCompOrDom = "."
End If
' Request the group name
strGroup = InputBox("Please enter a Group name", _
"ListGroupMembers Input Group Name", _
"Administrators", 100, 100)
If strGroup = "" Then
strGroup = "Users"
End If
' Create outputfile. Files will be created if not found, otherwise overwritten.
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\GroupMembers.txt", 2, True)
' Build the ADSI query and retrieve the group object
Set objWMIService = GetObject("WinNT://" & strCompOrDom & "/" & strGroup & ",group")
' Open the file and write computer name.
objFile.Write("Group Members for: " & strCompOrDom)
objFile.WriteBlankLines(1)
objFile.Write("Group: " & strGroup)
objFile.WriteBlankLines(1)
' Loop through the group membership and build a string containing the names
For Each objMember in objWMIService.Members
strMembers = strMembers + objMember.ADsPath + vbCrLf
Next
' Output the list
'WScript.Echo strMembers
objFile.Write (strMembers)
objFile.WriteBlankLines(1)
objFile.Close
WSHShell.Run "notepad.exe C:\GroupMembers.txt", 1, false
Note that wherever I wrote:
' change to your default domain
you should change to your domain. For example, our domain is: mydomain (Pre-Windows name, note the lack of .com - the .com might work, but easier is just to use the above)
Our domain is also: mydomainventure.com
Well, you get the point, our company name is where "mydomain" is.
The text output of the last script above is useful for removing old accounts from groups, because you can check the groups and any ofthe form S-1-256, etc. can by copied from the text file and inserted into the RemoveUserFromGroup script above (2nd script).
As to that reg entry, I wasn't aware of that, and will look into it myself. It could be useful round here.
hth,
Will