[personal profile] robopet3
[string]$proxydomain_1 = "@ xxx.ru"; #delete some whitespace
[string]$proxydomain_2 = "@ xxx.local"; #delete some whitespace
[string]$powersnapin = "Coexistence-Configuration"; #Directory Sync PS-Snapin name
[string]$email = $_.SamAccountName + '$proxydomain_1'
Import-Module ActiveDirectory
Get-ADUser -Filter "*" -SearchScope Subtree -Properties ProxyAddresses, givenName, Surname, mail | foreach-object {

Write-Host "Editing user: $_.SamAccountName"

if ($_.Proxyaddresses -match $_.SamAccountName+""+$proxydomain_1)
{
Write-Host "Result: Proxy Address already exists; No action taken."
}
else
{
Set-ADUser -Identity $_.SamAccountName -Remove @{Proxyaddresses="SMTP:"+$_.SamAccountName+""+$proxydomain_2}
Set-ADUser -Identity $_.SamAccountName -Remove @{Proxyaddresses="smtp:"+$_.SamAccountName+""+$proxydomain_1}
Set-ADUser -Identity $_.SamAccountName -Add @{Proxyaddresses="SMTP:"+$_.SamAccountName+""+$proxydomain_1}
Set-ADUser -Identity $_.SamAccountName -Add @{Proxyaddresses="smtp:"+$_.SamAccountName+""+$proxydomain_2}
}
#}

Profile

robopet3

May 2023

S M T W T F S
 12 3456
78910111213
14151617181920
21222324252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Feb. 22nd, 2026 05:54 pm
Powered by Dreamwidth Studios