> You're da the man! I noticed that once it creates the account it doesn't
> add
> it to local users group, is there an easy way to do that also?
>
> "Richard Mueller [MVP]" wrote:
>
>> No, the script will halt. To trap this possible error:
>> ============
>> '....
>> Do Until objFile.AtEndOfStream
>> strComputer = Trim(objFile.ReadLine)
>> ' Skip blank lines.
>> If (strComputer <> "") Then
>> ' Perform task on each computer.
>> ' Trap error if computer not available.
>> On Error Resume Next
>> Set colAccounts = GetObject("WinNT://" & strComputer)
>> If (Err.Number = 0) Then
>> ' Also trap error if you lack permission to create user.
>> Set objUser = colAccounts.Create("user", "user1")
>> If (Err.Number = 0) Then
>> On Error GoTo 0
>> objUser.SetPassword "mypassword"
>> objUser.SetInfo
>> Else
>> On Error GoTo 0
>> Wscript.Echo "Unable to create user on " & strComputer
>> End If
>> Else
>> On Error GoTo 0
>> Wscript.Echo "Unable to connect to " & strComputer
>> End If
>> End If
>> Loop
>> '....
>> --
>> Richard Mueller
>> Microsoft MVP Scripting and ADSI
>> Hilltop Lab -
http://www.rlmueller.net>> --
>> "morjo619" <morjo619[ at ]discussions.microsoft.com> wrote in message
>> news:79E0EC8E-8588-47D1-803B-AF27F05D7410[ at ]microsoft.com...
>> > Richard,
>> >
>> > Thank you for your help....looks like it's going to work. Do you know
>> > if
>> > it'll continue if comes accross a machine that it can't connect to?
>> >
>> > "Richard Mueller [MVP]" wrote:
>> >
>> >> morjo619 wrote:
>> >>
>> >> > Trying to figure out a way to run the script below for group of
>> >> > computers,
>> >> > could someone give a hand? Script adds a local user to the machine I
>> >> > specify,
>> >> > I need to to be able to do it in bulk. Thanks!
>> >> >
>> >> > Script:
>> >> > strComputer = "machin1"
>> >> > Set colAccounts = GetObject("WinNT://" & strComputer & "")
>> >> > Set objUser = colAccounts.Create("user", "user1")
>> >> > objUser.SetPassword "mypassword"
>> >> > objUser.SetInfo
>> >> >
>> >>
>> >> One idea would be to read computer names from a text file, using the
>> >> FileSystemObject. For example:
>> >> ============
>> >> Const ForReading = 1
>> >>
>> >> ' Specify text file with NetBIOS names of computers.
>> >> strFile = "c:\scripts\computers.txt"
>> >>
>> >> ' Open the text file for read access.
>> >> Set objFSO = CreateObject("Scripting.FileSystemObject")
>> >> Set objFile = objFSO.OpenTextFile(strFile, ForReading)
>> >>
>> >> ' Read names from file.
>> >> Do Until objFile.AtEndOfStream
>> >> strComputer = Trim(objFile.ReadLine)
>> >> ' Skip blank lines.
>> >> If (strComputer <> "") Then
>> >> ' Perform task on each computer.
>> >> Set colAccounts = GetObject("WinNT://" & strComputer)
>> >> Set objUser = colAccounts.Create("user", "user1")
>> >> objUser.SetPassword "mypassword"
>> >> objUser.SetInfo
>> >> End If
>> >> Loop
>> >>
>> >> ' Clean up.
>> >> objFile.Close
>> >>
>> >> --
>> >> Richard Mueller
>> >> Microsoft MVP Scripting and ADSI
>> >> Hilltop Lab -
http://www.rlmueller.net>> >> --
>> >>
>> >>
>> >>
>>
>>
>>