exist '.
Thanks again to both of you. :D
"LikeToCode" wrote:
> Hi Jarxale,
> I have found that the computer name must be exactly the computer name not
> "mycomputer.domain.com" or "." Allof your code looks fine and I agree you
> should remove the "On Error" statement. Also try the following statement in
> place of the one you have now.
> Set oGroup = GetObject("WinNT://" & sComputerName & "/Administrators,group")
> "Jarxale" wrote:
> > Hi all
> > I am working on a way to remotely create a local user account on one W2k3
> > server from W2k3 another server on a non-AD environment. For example, from
> > server A, I will create a new account onto Server B remotely.
> > Found this script from google but has an issue with it.
> > '--------------------8<----------------------
> > ' name of user to be created
> > sNewUser = "dummy"
> > ' name of the group the user is to be added to
> > sGroupname = "Administrators"
> > ' get computer name
> > Set oWshNet = CreateObject("WScript.Network" )
> > sComputerName = "ServerB"
> > ' connect to the Winnt provider
> > Set oComputer = GetObject("WinNT://" & sComputerName)
> > ' create the user
> > Set oUser = oComputer.Create("user", sNewUser)
> > oUser.SetPassword "qwerty@1"
> > On Error Resume Next
> > ' save the user
> > oUser.Setinfo
> > ' If user exists already or password restrictions
> > ' are not fulfilled, we get an error
> > If Err.Number = 0 Then
> > ' configure the user
> > On Error Goto 0
> > ' Enable "User Must Change Password at Next Logon"
> > oUser.Put "PasswordExpired", 1
> > oUser.Fullname = "Mr Dummy"
> > oUser.Description = "Dummy Sys Admin"
> > oUser.Setinfo
> > End If
> > On Error Goto 0
> > ' Add the user to the group
> > Set oGroup = GetObject("WinNT://" & sComputerName & "/" & sGroupname)
> > ' Use error handling in case he is a member already
> > On Error Resume Next
> > oGroup.Add(oUser.ADsPath)
> > On Error Goto 0
> > '--------------------8<----------------------
> > After execution, the new account is created with all the details as
> > specified in the script except for the Group section, which turns up empty.
> > Both servers are using the same credentials for login. Any help is
> > appreciated.
> > Regards :)