This script alters the emplids on all userobjects in AD in one run. Of course, the field employeeID needs to hold data before you can alter it.
In the script below, a "00" is put in front of the emplids of existing employees if the emplid has 4 characters. For other employees (like students, temps etc) the first character (in this case an "E") is replaced by "02". It also does an export to txt before and after the emplids are edited so you know what has changed.
Depending on the number of user objects in your AD this script could run for a while.
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
Set fs = CreateObject ("Scripting.FileSystemObject")
Set StartFile = fs.CreateTextFile ("c:\temp\StartFile.txt")
Set EndFile = fs.CreateTextFile ("c:\temp\EndFile.txt")
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = _
"SELECT ADsPath FROM 'LDAP://OU=Users,DC=Domain,DC=local' WHERE objectCategory='user'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
strPath = objRecordSet.Fields("ADsPath").Value
Set objUser = GetObject(strPath)
'Create a backup txt before updating userdata
StartFile.Write objUser.employeeID & ";" & objUser.samAccountName & ";" & objUser.FullName & ";" & objUser.department
StartFile.WriteLine ""
strEmplId = objUser.employeeID
If Left(objUser.employeeID,1)="E" Then
strNewEmplId = Replace(strEmplId,"E","02")
objUser.Put "employeeID", strNewEmplId
objUser.SetInfo
Else
If Len(strEmplId) = 4 Then
objUser.Put "employeeID", "00" + objUser.employeeID
objUser.SetInfo
Else
'Do Nothing
End If
End If
'Create a control txt after updating userdata
EndFile.Write objUser.employeeID & ";" & objUser.samAccountName & ";" & objUser.FullName & ";" & objUser.department
EndFile.WriteLine ""
objRecordSet.MoveNext
Loop