Due to a company take-over we had to modify the primary proxyaddress of users and public folders.
Unfortunatly all tests using ADModify which is a great tool didn't work. A modification with recipient policies and RUS seemed to be too critical, because most addresses had been modified different times and some tests did not have the expected result. So we decided to write some code using Powershell. We used Quest Power GUI with Active Roles Management Shell for Active Directory (free download) and installed .NET 3.1 and Powershell 1.0 on an Exchange 2003 SP2 Server / German language.
In 3 code snippets we delete a given secondary proxyaddress from users in a given group. Then we add a new primary proxyaddress and in third step we change the old primary address into a secondary address.
Code Snippet 1:
# download here: RemoveSecondarySMTPOfUsers.txt
# Aus der Gruppe die Mitgliedschaften auslesen
#
"Programmstart"
$gruppe=get-qadgroup -display "Umstellung"
# über alle Gruppenmember laufen
for ($memberCount=0; $memberCount -le $gruppe.member.count-1; $memberCount++)
{
$userLangName=$gruppe.member[$memberCount]
$user=[ADSI]"LDAP://$userLangName"
$email=$user.proxyAddresses
# über alle ProxyAdressen des Users laufen
for ($adrCount=0; $adrCount -le $email.count-1 ;$adrCount++)
{
$fulladdress=$email[$adrCount]
# Typ-Teil (SMTP, X400 etc.)
$typ=$fulladdress.substring(0,5)
# wirkliche E-Mail-Adresse (foo@bar.com)
$address=$fulladdress.substring(5)
# evtl. bestehende sekundäre bgetem.de-Adresse löschen
if($typ -ceq "smtp:" -and $address -match "bgetem.de$")
{
#$email.Remove("$fulladdress")
$user.proxyAddresses.Remove("$fulladdress")
"alte BGETEM-Adresse $fulladdress gelöscht"
}
}
# Änderungen wegschreiben
$user.setinfo()
}
Code Snippet 2:
# download here:
AddNewPrimarySMTPOfUsers.txt
# Aus der Gruppe die Mitgliedschaften auslesen
#
"Programmstart"
$gruppe=get-qadgroup -display "Umstellung"
# über alle Gruppenmember laufen
for ($memberCount=0; $memberCount -le $gruppe.member.count-1; $memberCount++)
{
$userLangName=$gruppe.member[$memberCount]
$user=[ADSI]"LDAP://$userLangName"
$email=$user.proxyAddresses
# über alle ProxyAdressen des Users laufen
for ($adrCount=0; $adrCount -le $email.count-1 ;$adrCount++)
{
$fulladdress=$email[$adrCount]
# Typ-Teil (SMTP, X400 etc.)
$typ=$fulladdress.substring(0,5)
# wirkliche E-Mail-Adresse (foo@bar.com)
$address=$fulladdress.substring(5)
# bgete.de-Adresse ermitteln und als neue primäre SMTP auf bgete_M_.de speichern
if ($typ -ceq "SMTP:" -and $address -match "bgete.de$")
{
$newaddress = $address.Substring(0, $address.Length - 3) + "m.de"
$newaddress = $newaddress.ToLower()
$user.proxyAddresses += "SMTP:$newaddress"
"neue BGETEM-Adresse $newaddress für $fulladdress hinzugefügt"
}
}
# Änderungen wegschreiben
$user.setinfo()
}
Code Snippet 3:
# Download here: RemovePrimarySMTPOfUsers.txt
# Aus der Gruppe die Mitgliedschaften auslesen
#
"Programmstart"
$gruppe=get-qadgroup -display "Umstellung"
# über alle Gruppenmember laufen
for ($memberCount=0; $memberCount -le $gruppe.member.count-1; $memberCount++)
{
$userLangName=$gruppe.member[$memberCount]
$user=[ADSI]"LDAP://$userLangName"
$email=$user.proxyAddresses
# über alle ProxyAdressen des Users laufen
for ($adrCount=0; $adrCount -le $email.count-1 ;$adrCount++)
{
$fulladdress=$email[$adrCount]
# Typ-Teil (SMTP, X400 etc.)
$typ=$fulladdress.substring(0,5)
# wirkliche E-Mail-Adresse (foo@bar.com)
$address=$fulladdress.substring(5)
# bgete.de-Adresse ermitteln und auf kleingeschriebens SMTP umstellen
if ($typ -ceq "SMTP:" -and $address -match "bgete.de$")
{
$modifiedFullAddress = "smtp:" + $address.ToLower()
$email[$adrCount] = $modifiedFullAddress
"auf kleines smtp für $address geändert"
}
}
# Änderungen wegschreiben
$user.setinfo()
}

Hey - nice blog, just looking around some websites, seems a pretty nice platform you are using. I'm currently using Wordpress for a few of my blogs but looking to change one of them over to a platform similar to yours as a trial run. Anything in particular you would recommend about it?