VBS AD Question
I am working on automating some of our account creation. Here is a snippet from the script I am using:
Only problem is that once in a while, someone will send me a spreadsheet that has a few user accounts that have already been created, which causes an error that terminates the script.
While Not tsInputFile.AtEndOfStream
strLine = tsInputFile.ReadLine
arrInput = Split(strLine, ",")
Set objUser = objDomain.Create("user","cn=" & arrInput(1) & " " & arrInput(0))
objUser.Put "givenName", arrInput(1)
ObjUser.Put "sn", arrInput(0)
ObjUser.Put "displayName", arrInput(1) & " " & arrInput(0)
objUser.Put "sAMAccountName", arrInput(2)
objUser.Put "userPrincipalName", arrInput(2) & "@***"
What I would like to do, is to tell it that if an account exists, to move on to the next line in the CSV file. I am guessing this should be fairly simple, but I am not sure of the syntax when dealing with AD to make this happen. Anyone have any experience with this? I have searched around, but haven't had much luck finding anything.
Nice! Sometimes simple is the best option. I will give it a shot.
Worked like a charm. Thanks again.