<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://wiki.twig.es/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.twig.es/index.php?action=history&amp;feed=atom&amp;title=Updating_ProxyAddresses%2C_Example_6</id>
		<title>Updating ProxyAddresses, Example 6 - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.twig.es/index.php?action=history&amp;feed=atom&amp;title=Updating_ProxyAddresses%2C_Example_6"/>
		<link rel="alternate" type="text/html" href="https://wiki.twig.es/index.php?title=Updating_ProxyAddresses,_Example_6&amp;action=history"/>
		<updated>2026-05-06T17:35:38Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.0</generator>

	<entry>
		<id>https://wiki.twig.es/index.php?title=Updating_ProxyAddresses,_Example_6&amp;diff=1355&amp;oldid=prev</id>
		<title>George2: Created page with &quot;&lt;source lang=&quot;powershell&quot;&gt;  Import-module activedirectory Function Set-DefaultAddress ([string]$UserName,[string]$NewDefaultAddress) {     $NewProxyAddresses=@()     $AddressF...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.twig.es/index.php?title=Updating_ProxyAddresses,_Example_6&amp;diff=1355&amp;oldid=prev"/>
				<updated>2014-11-11T13:11:55Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;source lang=&amp;quot;powershell&amp;quot;&amp;gt;  Import-module activedirectory Function Set-DefaultAddress ([string]$UserName,[string]$NewDefaultAddress) {     $NewProxyAddresses=@()     $AddressF...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;powershell&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Import-module activedirectory&lt;br /&gt;
Function Set-DefaultAddress ([string]$UserName,[string]$NewDefaultAddress) {&lt;br /&gt;
    $NewProxyAddresses=@()&lt;br /&gt;
    $AddressFoundInArray=$False&lt;br /&gt;
    Write-Debug &amp;quot;Processing user $UserName&amp;quot;&lt;br /&gt;
    $ProxyAddresses=(Get-ADUser $UserName -Properties proxyaddresses).proxyaddresses&lt;br /&gt;
    foreach ($ProxyAddress in $ProxyAddresses) {&lt;br /&gt;
        #Only evaluate smtp addresses&lt;br /&gt;
        if ($ProxyAddress -match &amp;quot;^smtp:&amp;quot;) {&lt;br /&gt;
            $ProxyAddressArr=$ProxyAddress.Split(&amp;quot;:&amp;quot;)&lt;br /&gt;
            If ($ProxyAddressArr[1] -eq $NewDefaultAddress) {&lt;br /&gt;
                Write-Debug &amp;quot;Address $NewDefaultAddress found, converting to default address&amp;quot;&lt;br /&gt;
                $NewProxyAddresses+=$proxyAddressArr[0].ToUpper()+&amp;quot;:&amp;quot;+$ProxyAddressArr[1]&lt;br /&gt;
                $AddressFoundInArray=$True&lt;br /&gt;
            } else {&lt;br /&gt;
                Write-Debug &amp;quot;Converting $ProxyAddress to non-default address&amp;quot;&lt;br /&gt;
                $proxyAddressArr[0]=$proxyAddressArr[0].ToLower()&lt;br /&gt;
                $NewProxyAddresses+=$proxyAddressArr[0].ToLower()+&amp;quot;:&amp;quot;+$ProxyAddressArr[1]&lt;br /&gt;
            }&lt;br /&gt;
        } else {&lt;br /&gt;
            $NewProxyAddresses+=$ProxyAddress&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    if (!$AddressFoundInArray) {&lt;br /&gt;
        Write-Debug &amp;quot;Adding address $NewDefaultAddress&amp;quot;&lt;br /&gt;
        $NewProxyAddresses+=&amp;quot;SMTP:$NewDefaultAddress&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
    Set-ADUser $UserName -Replace @{ProxyAddresses=$NewProxyAddresses} -EmailAddress $NewDefaultAddress&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>George2</name></author>	</entry>

	</feed>