Edit script

Can someone please tell me how to edit this script so that it does not clear the workstation entries that are already enterered into the logon workstations field, and instead appends new entries? <Script Below>

Thanks,


Set filesys = CreateObject("Scripting.FileSystemObject")

Dim myfile
If filesys.FileExists("macs.csv") Then
   Set myfile = filesys.OpenTextFile("macs.csv")
Else
   MsgBox "Could not find file dbs.csv",0,"Error Finding File"
   Wscript.Quit
End If

Dim line, segs
Dim UserID, WorkStations
while not myfile.AtEndOfLine
    line = myfile.ReadLine
    segs = Split(line,",")

    UserID = segs(0)
    WorkStations = segs(1) & "," & segs(2) & "," & segs(3)
    Call ChangeLocalWorkStation(UserID,WorkStations)
wend




Sub ChangeLocalWorkStation(UserID,WorkStations)

     Dim server
     server = "DC1" ' Change this to the server you like to make changes on
     
     Dim Conn, Base, Filter, Attr, Tree, Root
     Set Conn = CreateObject("ADODB.Connection")
     Conn.Provider = "ADsDSOObject"
     Conn.Open "Active Directory Provider"
     
     Base   = "<LDAP://" & server & "/OU=Users,DC=Corp,DC=Net>;"  ' Change DC=CORP,DC=NET to your own
     filt   = "(&(objectClass=user)(objectCategory=person)(samAccountName=" & UserID & "));"
     Attr   = "distinguishedName;"
     Tree   = "SubTree"
     
     Dim rs
     Set rs = Conn.Execute(Base & filt & Attr & Tree)
     Dim dn, obj, wks
     rs.MoveFirst
     
                While Not rs.EOF
           dn = rs.Fields(0).Value
           Set obj = GetObject("LDAP://" & server & "/" & dn)
           obj.Put "userWorkstations", WorkStations
           obj.SetInfo
           wks = obj.Get("userWorkstations")
           Wscript.echo "Changed " & UserID & " userWorkstations to " & wks
           rs.MoveNext
     Wend
     
End Sub
LVL 1
fil1951Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris DentPowerShell DeveloperCommented:

Should be easy enough to read whatever is there at the moment and append your new list onto the end of that:

strCurrentWorkstations = obj.Get("userWorkstations")
WorkStations = strCurrentWorkstations & "," & WorkStations
obj.Put "userWorkstations", Workstations
obj.SetInfo

HTH

Chris

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fil1951Author Commented:
Works great! Thanks for your help.
Chris DentPowerShell DeveloperCommented:

No problem :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.