I've recently had to replace the Primary SMTP address for all users within an organisation. Of course this is a lot easier if you script it.
I needed to do this as the client was changing their primary address, but wanted to retain all the current proxyAddresses as well.
This was achieved by using two scripts.
$Users = Get-ADUser -SearchBase 'OU=ouname,OU=ouname,OU=ouname,OU=ouname,DC=domai,DC=com,DC=au' -Filter * -Properties mail,ProxyAddresses | Select-Object samaccountname,ProxyAddresses
Foreach ($User in $Users)
{
$Samaccountname = $User.samaccountname
$SMTP = "SMTP:$samaccountname@newdomain.com.au"
Set-ADUser $samaccountname -Add @{proxyAddresses=$SMTP}
}
This script adds the new SMTP address for all users within a certain OU. Of course this will cause some troubles on its own, as there's now going to be two SMTP addresses, marked as primary.
The following script clears this up:
Get-ADUser -SearchBase 'OU=ouname,OU=ouname,OU=ouname,OU=ouname,DC=domai,DC=com,DC=au' -Filter * -Properties mail,ProxyAddresses |
Foreach {
$proxies = $_.ProxyAddresses |
ForEach-Object{
$a = $_ -replace 'SMTP','smtp'
if($a -match 'newdomain.com.au'){
$a -replace 'smtp','SMTP'
}else{
$a
}
}
$_.ProxyAddresse = $proxies
Set-ADUser -instance $_
}
This will remove smtp:firstname.lastname@domain.com and replace it with SMTP:firstname.lastname@domain.com
ReplyDelete[string]$proxydomain = "@Domain.com.au"; #Proxy domain
[string]$usersOU = "OU=Users,DC=Domain,DC=local"; #OU to apply changes
[int]$count = 0 ;
Import-Module ActiveDirectory
Get-ADUser -Filter "*" -SearchScope Subtree -SearchBase "$usersOU" -Properties proxyAddresses, employeeType, givenName, Surname | foreach-object {
Write-Host "Editing user: $_.SamAccountName"
if ($_.Proxyaddresses -match $_.givenName+"."+$_.Surname+$proxydomain)
{
Set-ADUser -Identity $_.SamAccountName -remove @{proxyAddresses="smtp:"+$_.givenName+"."+$_.Surname+$proxydomain}
Write-Host "Removed '$_.SamAccountName' smtp Address"
Set-ADUser -Identity $_.SamAccountName -add @{proxyAddresses="SMTP:"+$_.givenName+"."+$_.Surname+$proxydomain}
Write-Host "Result: Added '$_.SamAccountName' Proxy address."
$count++
}
else
{
Write-Host "Nothing Changed."
}
}
Write-Host "Sucessfully Edited" $count "users"
Great, that has done it for me!
DeleteThank you
GOOGLE1
ReplyDeleteGOOGLE2
GOOGLE3
GOOGLE4
GOOGLE5
end of lease cleaning sydney
ReplyDeleteprimevideo.com/mytv
ReplyDeleteamazon.com/mytv
amazon.com/mytv
amazon.com/mytv
amazon.fr/mytv
amazon.de/mytv
ReplyDeleteamazon.com.mx/mytv
www.amazon.co.jp/mytv
www.amazon.it/mytv
primevideo.com/mytv
amazon.de/mytv
ReplyDeleteamazon.co.jp/mytv
Amazon Prime Customer Service Number
Amazon.com/help
ebay.com/login
Devotional Songs Lyrics
This is good step because many new users were facing issues during replacing their script, but now they are happy because with the help of this content, they can solve their issues easily. Coursework writing services.
ReplyDeleteQuickPay Portal | www.quickpayportal.com | Pay Your Medical Bill
ReplyDeletePay Your Medical Bill using www.quickpayportal.com and Make a quick and fast payment online using the QuickPay Portal. Just find your QuickPay Code on your billing statement and and you're ready to go
quickpayportal.com
quickpayportal.com
quickpayportal.com
Pragmatic Play
ReplyDeleteJudi Online
Agen Live Casino
ReplyDeleteAgen Sbobet
Pragmatic Play
nouveaupouvoir
philablazers
soobahkdo
ukiphome
autoandrive
loureedforum
You have shared a very nice post but to be honest, I do not have enough time to complete it because I have to find a Research Article Writer for Publication of my article. Although, I would feel great to complete it first, but I have to find a writer on a very urgent basis.
ReplyDeletegoogle 218
ReplyDeletegoogle 219
google 220
google 221
ReplyDeletehttp://94.237.75.108/
Slot Pulsa Pragmatic Play banyak sekali yang menyediakan berbagai permainan mesin slot gacor online uang asli terlengkap.
ReplyDeletehttp://94.237.75.108/ banyak sekali yang menyediakan berbagai permainan mesin slot gacor online uang asli terlengkap.
ReplyDeleteJupiter Solar
ReplyDeleteAbout Jupiter Solar
Glass lined solar water heater
Ceramic Coated Solar Water Heater
Stainless Steel Solar Water Heater
Copper Tank solar water heater
solar water heater Frequently Asked Questions Jupiter Solar
Contact us Jupiter Solar
It can also be a component transfusion to slenderize into more detail about the us and electrolyte of a significant in proffer to accept which available laryngeal effects are close by, and how they can other you. Nigczv zrkqee http://94.237.70.173/
ReplyDeleteQuick Pay Portal
ReplyDeleteThe team created the quickpayportal.com website to give you the option to pay your medical bills right away. Located in Massachusetts, the QuickPay Portal Bill Pay is set up by Athena physicians .
Visit:- QuickPay Portal Com
Perkenalkan REPUBLIKSLOT yakni situs slot online 24 jam terbaik 2022 yang menyediakan ribuan mesin slot pulsa gacor mudah menang jackpot terbesar dan judi fafaslot 88 terpercaya di Indonesia melalui link slot pulsa xl alternatif resmi PASTI BAYAR. Nikmati setiap kemudahan bermain slot online24jam tanpa potongan minimal 10rb dan bonus new member 100% di awal to kecil segera dan bonus besar lainnya tanpa diundi. alternatif link kunjungi https://conecta.bio/slotxl
ReplyDeleteThis comment has been removed by the author.
ReplyDeletehttp://198.252.110.45/
ReplyDelete