Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Creating local user account remotely
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jarxale  
View profile  
 More options Nov 13 2009, 3:17 am
Newsgroups: microsoft.public.scripting.vbscript
From: Jarxale <Jarx...@discussions.microsoft.com>
Date: Thu, 12 Nov 2009 19:17:01 -0800
Local: Fri, Nov 13 2009 3:17 am
Subject: Creating local user account remotely
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 :)


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Al Dunbar  
View profile  
 More options Nov 13 2009, 3:33 am
Newsgroups: microsoft.public.scripting.vbscript
From: "Al Dunbar" <aland...@hotmail.com>
Date: Thu, 12 Nov 2009 20:33:28 -0700
Local: Fri, Nov 13 2009 3:33 am
Subject: Re: Creating local user account remotely

"Jarxale" <Jarx...@discussions.microsoft.com> wrote in message

news:1EEB77DE-A2BF-494C-B58D-73A85EE06BFF@microsoft.com...

Try removing the "on error resume next" statement and you might see what
kind of error the .add is generating.

/Al


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
LikeToCode  
View profile  
 More options Nov 14 2009, 2:06 am
Newsgroups: microsoft.public.scripting.vbscript
From: LikeToCode <LikeToC...@discussions.microsoft.com>
Date: Fri, 13 Nov 2009 18:06:01 -0800
Local: Sat, Nov 14 2009 2:06 am
Subject: RE: Creating local user account remotely
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")


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jarxale  
View profile  
 More options Nov 14 2009, 5:00 am
Newsgroups: microsoft.public.scripting.vbscript
From: Jarxale <Jarx...@discussions.microsoft.com>
Date: Fri, 13 Nov 2009 21:00:01 -0800
Local: Sat, Nov 14 2009 5:00 am
Subject: RE: Creating local user account remotely
SOLVED: I removed the On Error statement, got this error msg ' A member could
not be added to or removed from the local group because the member does not
exist '.

Found this article, http://kb.parallels.com/en/3939.

Realised I made a silly mistake, I have been using the IP address of the
server for the computer name, switched it back to hostname and everything
works.

FYI LikeToCode the alternative statement you suggested for the adding to
group works fine too.

Thanks again to both of you. :D


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2010 Google