Essentially, I've created the following to add to our environment three users to a desktop: BKRADM, CTC_ITSPRT, MUSR_MQADMIN then make two groups:
mqm and mqbrkrs, then put those three users into those two groups.
My problem is:
Based on the script below how do I..
1) Add to groups mqm and mqbrkrs the last three logged in users to that local machine I run the vb script on and..
2) Manually add in domain users where I want to add to, say, the mqm group a user CORP om.jones and CORPertha.matt (both users are in our network domain and not local users to the computer so its critical to have the CORP there also). I can add local users but no idea how to add CORP domain users.
[code]'Set System to ignore errors and continue
On Error Resume Next
'Declare Variable for Shell Object
Dim WshShell
Set WshShell = WScript.CreateObject("Wscript.Shell")
'Declare Variable for Network Object
Dim WshNet
Set WshNet = WScript.CreateObject("WScript.Network")
'Declare Variable for Filesystem Object
Dim WshFileSys
Set WshFileSys = WScript.CreateObject("Scripting.FileSystemObject")
'Set Constants for file access (read, write, append)
Const ForReading = 1, ForWriting = 2, ForAppending = 8
'Declare Variable for Network Object
Dim net, local, objUser2, objUser3, objDomain, UserID, ObjNet
Set net = WScript.CreateObject("WScript.Network")
local = net.ComputerName
objDomain = net.UserDomain
objUser3 = net.UserName
Set UserID = objDomain & "" & objUser3
'WScript.Echo UserID
Set colAccounts = GetObject("WinNT://" & local & ",computer")
Set objUser = colAccounts.Create("user", "BKRADM")
objUser.SetPassword "P@ssw0rd"
objUserFlags = objUser.Get("UserFlags")
'Password will never expire!
objPasswordExpirationFlag = objUserFlags OR ADS_UF_DONT_EXPIRE_PASSWD
objUser.Put "userFlags", objPasswordExpirationFlag
objUser.SetInfo
Set colAccounts = GetObject("WinNT://" & local & ",computer")
Set objUser1 = colAccounts.Create("user", "CTC_ITSPRT")
objUser1.SetPassword "P@ssw0rd"
objUserFlags = objUser.Get("UserFlags")
objUser1.SetInfo
Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000
Set colAccounts = GetObject("WinNT://" & local & ",computer")
Set objUser2 = colAccounts.Create("user", "MUSR_MQADMIN")
objUser2.SetPassword "P@ssw0rd"
objUserFlags = objUser.Get("UserFlags")
'Password will never expire!
objPasswordExpirationFlag = objUserFlags OR ADS_UF_DONT_EXPIRE_PASSWD
objUser2.Put "userFlags", objPasswordExpirationFlag
objUser2.SetInfo
Set colAccounts = GetObject("WinNT://" & local & "")
Set objGroup = colAccounts.Create("group", "mqm")
objGroup.SetInfo
Set colAccounts = GetObject("WinNT://" & local & "")
Set objGroup = colAccounts.Create("group", "mqbrkrs")
objGroup.SetInfo
Set ObjGroup = GetObject("WinNT://" & local & "/mqm,group")
objGroup.Add(ObjUser2.ADsPath)
Set UserID = objDomain & "/" & objUser3
Set ObjNet = GetObject("WinNT://" & objDomain & "/" & objUser3 & ",user")
Set ObjGroup = GetObject("WinNT://" & local & "/mqbrkrs,group")
objGroup.Add(ObjUser2.ADsPath)
objGroup.Add(ObjNet.ADsPath)
objGroup.Add(ObjUser.ADsPath)
objGroup.Add(ObjUser1.ADsPath)
Set objUser = GetObject("WinNT://" & objDomain & "/" & objUser2)
Set ObjGroup = GetObject("WinNT://" & local & "/mqm,group")
objGroup.Add(ObjUser2.ADsPath)
objGroup.Add(ObjNet.ADsPath)
objGroup.Add(ObjUser.ADsPath)
objGroup.Add(ObjUser1.ADsPath)[/code]
Thanks VBS community!