In fact I just did something like this a few days ago, but for the opposite reason (post divestiture cleanup).
I don't see the putex statement in your script - you can't do a substring search across elements of an array, as in the line where you're doing REPLACE(...) You need to do a PutEx to put the correct element in. The following deletes an item, but changing it to ADS_PROPERY_UPDATE would change that. entry.PutEx ADS_PROPERTY_DELETE, "otherMailbox", Array(a1(0) & "$" & a1(1)) Also note that the separator is not a ':' between SMTP and the address, it's a '$' Roger -------------------------------------------------------------- Roger D. Seielstad - MCSE Sr. Systems Administrator Inovis Inc. > -----Original Message----- > From: Veld, Paul [mailto:[EMAIL PROTECTED] > Sent: Tuesday, March 25, 2003 1:38 AM > To: Exchange Discussions > Subject: Change the primary SMTP address using VBscript > > > Has anyone tried to use a VBscript to change the primary SMTP > address for a number of users? > > We are in the process of a demerger. During the transition > process, all the users in the new company need to have some > additional SMTP addresses. After a certain date, the primary > SMTP address needs to be changed from the existing Company1 > address to the new Company2 address. I have tried to do this > in a script, but it doesn't do what I want. The script > basically goes through a particular OU ( containing all the > user accounts which are migrating to the new company ), > extracts the proxy addresses for each user into an array, > then reads through the array and modifies the appropriate > values. It then writes the array back to the user object and > loops back to the next user. It runs with no error, but when > I look at the user's properties, the primary SMTP address has > not been changed. > > Has anyone done this before?? Can anyone see what I'm doing > wrong?? As you can probably see from the code, I'm not a > scripting guru. I have googled and looked at as many sample > scripts ( MSDN, Script Center etc ) as I could find, but I > wasn't able to find any code specifically about changing the > primary SMTP address. > > Any assistance gratefully accepted. > > Code extract follows .............. > > ' > -------------------------------------------------------------- > ----------- > Option Explicit > > Dim objDSE, strDefaultDN, strDN, objContainer, objChild > Dim ObjUser, arrProxy, strProxy, strValue, arrayValues(3) > Dim strEmail, strEmail1, strEmail2, strEmail3, strEmail4 > Dim fso, outputfile, i, strAlias, strMail > > Const E_ADS_PROPERTY_NOT_FOUND = &h8000500D > Const ADS_PROPERTY_UPDATE = 2 > Const ADS_PROPERTY_APPEND = 3 > > On Error Resume Next > > ' Bind to rootDSE and establish the connection to the OU > Set objDSE = GetObject("LDAP://rootDSE") > strDefaultDN = "OU=Test," & objDSE.Get("defaultNamingContext") > Set objContainer = GetObject("LDAP://" & strDefaultDN) > > objContainer.Filter = Array("user") ' only want to process > user objects > > i = 0 > strEmail = "" > > For Each objChild In objContainer ' loop through users in OU > Wscript.echo " " > WScript.Echo objChild.Name & vbTab & > objChild.Description & vbTab & objChild.distinguishedname > Wscript.echo " " > set objUser = GetObject("LDAP://" & > objChild.distinguishedname) ' > bind to user object > arrProxy = objUser.GetEx("proxyAddresses") ' load proxy > addresses into an array > > i = 0 > strEmail = "" > > If err.number = E_ADS_PROPERTY_NOT_FOUND Then ' if > the property is > not found, display message > Wscript.echo "No proxy addresses - property not found" > err.clear > Else > If isEmpty(arrProxy) Then ' if no proxy > addresses, display message > Wscript.echo "No proxy addresses - empty array" > Else > wscript.echo (ubound(arrProxy)+1) & " proxy > addresses found" > dim arrNewproxy() > For i = 0 To Ubound ( arrProxy ) ' loop through > proxy addresses > strProxy = arrProxy(i) > 'Wscript.echo "old " & i & " > strProxy: " & > strProxy > If ( InStr ( strProxy, "SMTP:" > ) > 0 ) Then > ' is this the primary SMTP address? > strProxy = Lcase(strProxy) > End If > If ( InStr ( strProxy, "bogus1" > ) > 0 ) Then > ' is this the new primary SMTP address? > strProxy = > Replace(strProxy, "smtp", > "SMTP") > End If > arrNewproxy(i) = strProxy > 'Wscript.echo "new " & i & " strProxy: > " & strProxy > Next ' i > objUser.PutEx ADS_PROPERTY_UPDATE, > "msExchPoliciesExcluded", > Array("{26491CFC-9E50-4857-861B-0CB8DF22B5D7}") > ' clear the -use recipient policies- field > objUser.PutEx ADS_PROPERTY_UPDATE, > "proxyAddresses", > Array(arrNewproxy) > objUser.SetInfo > ' apply the changes we have made to the object > set objUser = Nothing > ' release the user object binding > End If > End If > Next > > _________________________________________________________________ > List posting FAQ: http://www.swinc.com/resource/exch_faq.htm > Archives: http://www.swynk.com/sitesearch/search.asp > To unsubscribe: mailto:[EMAIL PROTECTED] > Exchange List admin: [EMAIL PROTECTED] > _________________________________________________________________ List posting FAQ: http://www.swinc.com/resource/exch_faq.htm Archives: http://www.swynk.com/sitesearch/search.asp To unsubscribe: mailto:[EMAIL PROTECTED] Exchange List admin: [EMAIL PROTECTED]

