I’m writing a script that will create users in Active Directory. The script runs OK and does what I want it to, but I’m trying to report any errors to a text file.
See Sample extract below, using arrInput variables:
Set objUser = objOU.Create(“User”, “cn=” & arrInput(1))
objUser.Put “sAMAccountName”, arrInput(1)
objUser.Put “userPrincipalName”, arrInput(1) & “@hcctest.gov.uk”
objUser.SetInfo
If Err.Number = 0 Then
f.Write arrInput(4) & ” – ” & Err.Number & ” – ” & Err.Description f.WriteBlankLines(1)
Err.Clear
f.close
Else
‘wscript.echo arrInput(4) & ” Created successfully”
f.Write arrInput(4) & ” Created successfully”
f.WriteBlankLines(1)
f.Close
End If