{"id":1648,"date":"2022-11-29T12:58:10","date_gmt":"2022-11-29T11:58:10","guid":{"rendered":"https:\/\/www.web-workers.ch\/?p=1648"},"modified":"2022-11-29T12:58:16","modified_gmt":"2022-11-29T11:58:16","slug":"how-to-add-modify-delete-smtp-proxy-attribute","status":"publish","type":"post","link":"https:\/\/www.web-workers.ch\/index.php\/2022\/11\/29\/how-to-add-modify-delete-smtp-proxy-attribute\/","title":{"rendered":"How to add\/modify\/delete SMTP proxy attribute"},"content":{"rendered":"\n<p>proxyAddresses is a multivalued attribute in Active Directory (AD) used on users, groups, and contacts to<span>&nbsp;<\/span><em>facilitate mail delivery<\/em>.<\/p>\n<p>To configure this attribute using PowerShell, you need the ActiveDirectory Module for PowerShell. This module is part of<span>&nbsp;<\/span><a href=\"https:\/\/www.easy365manager.com\/how-to-install-rsat-remote-server-administration-tools\/\">RSAT<\/a><span>&nbsp;<\/span>(Remote Server Administration Tools) which you need to activate (or download depending on your OS version). It\u2019s available by default on domain controllers.<\/p>\n<p>Before you start editing the proxyAddresses attribute, you should understand the following:<\/p>\n<ul>\n<li>You must prefix the primary (sending) mail alias with upper case \u201cSMTP:\u201d<\/li>\n<li>Only one value\/alias is allowed to have the upper case \u201cSMTP:\u201d prefix<\/li>\n<li>You must prefix secondary mail aliases with lower case \u201csmtp:\u201d<\/li>\n<li>No duplicate values (across all AD objects) are allowed<\/li>\n<li>Mail addresses must be valid SMTP addresses as per<span>&nbsp;<\/span><a href=\"https:\/\/tools.ietf.org\/html\/rfc5322\" target=\"_blank\" rel=\"noopener\">RFC 5322<\/a><\/li>\n<li><em>Faulty configurations of this attribute can potentially break mail delivery for the recipient<\/em><\/li>\n<li><em>Active Directory makes&nbsp;no sanity check on values you enter\/update\/delete<\/em><\/li>\n<li><em>It\u2019s a multivalued attribute, and wrong commands may unintentionally overwrite existing values<\/em><\/li>\n<\/ul>\n<h2>Modify proxyAddresses<\/h2>\n<p>Launch the poweshell as administrative user.<\/p>\n<h5>Add SMTP proxy attribute<\/h5>\n<div class=\"elementor-element elementor-element-0a959aa elementor-widget elementor-widget-text-editor\" data-id=\"0a959aa\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<div class=\"elementor-text-editor elementor-clearfix\">\n<p>The following command will import a single value to the multivalued proxyAddresses attribute. Any existing values are kept.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-plain\" data-lang=\"Plain Text\"><code>Import-Module ActiveDirectory<br>Set-ADUser &lt;Some_Username&gt; -add @{ProxyAddresses=\"SMTP:some.email@address.info\"}<\/code><\/pre>\n<\/div>\n<h5>List SMTP proxy attribute<\/h5>\n<p>The following command will display all smtp entries from the proxyAddresses attribute.<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-plain\" data-lang=\"Plain Text\"><code>Import-Module ActiveDirectory<br>Get-ADUser -Identity &lt;Some_Username&gt; -Properties proxyaddresses | Select-Object Name, @{L = \"ProxyAddresses\"; E = { ($_.ProxyAddresses -like 'smtp:*') -join \";\"}}<\/code><\/pre>\n<\/div>\n<h5>Remove SMTP proxy attribute<\/h5>\n<div class=\"elementor-element elementor-element-b5c19b4 elementor-widget elementor-widget-text-editor\" data-id=\"b5c19b4\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<div class=\"elementor-text-editor elementor-clearfix\">\n<p>The following command will remove a single entry from the proxyAddresses attribute. Any other existing values are kept.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-plain\" data-lang=\"Plain Text\"><code>Import-Module ActiveDirectory<br>Set-ADUser &lt;Some_Username&gt; -Remove @{ProxyAddresses=\"SMTP:some.email@address.info\"}<\/code><\/pre>\n<\/div>\n\n\n\n<h2>Export proxyAddresses to CSV<\/h2>\n<p>Use the following script to export all proxyAddresses for all AD objects. The script generates one line for each individual value of each proxyAddresses attribute value of each AD object. This means you will have four lines for a user with one primary SMTP alias and three secondary SMTP alias\u2019s.<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-plain\" data-lang=\"Plain Text\"><code>Import-Module ActiveDirectory\n\"DN;proxyAddress\" | Out-File \".\\proxyAddressesBackup.txt\"\n$Objects = Get-ADObject -LDAPFilter \"(proxyAddresses=*)\" -Properties proxyAddresses\nForEach ($Object In $Objects) {\n  ForEach ($proxyAddress in $Object.proxyAddresses) {\n    $Output = $Object.distinguishedName + \";\" + $proxyAddress\n    Write-Host $Output\n    $Output | Out-File \".\\proxyAddressesBackup.txt\" -Append\n  }\n}<\/code><\/pre>\n<\/div>\n\n\n\n<h2>Filter proxyAddresses With LDAP Query<\/h2>\n<p><span>As an example, let\u2019s identify all users that have a \u201c.local\u201d mail address (having a .local proxyAddress will block the user from replicating to Azure with Azure AD Connect):<\/span><\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-plain\" data-lang=\"Plain Text\"><code>Import-Module ActiveDirectory\n$Users = Get-ADUser -LDAPFilter \"(proxyAddresses=*.local)\" -Properties proxyAddresses\nForEach ($User In $Users) {\n  ForEach ($proxyAddress in $User.proxyAddresses) {\n    If($proxyAddress -Like '*.local'){\n    Write-Host $User.distinguishedName `t $proxyAddress\n    }\n  }\n}<\/code><\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>proxyAddresses is a multivalued attribute in Active Directory (AD) used on users, groups, and contacts to&nbsp;facilitate mail delivery. To configure this attribute using PowerShell, you need the ActiveDirectory Module for [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1290,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[173,138,3,171],"tags":[63,139,174,29],"class_list":["post-1648","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-active-directory","category-exchange-server","category-mswin","category-office-365","tag-ad","tag-exchange","tag-proxyaddress","tag-server"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.web-workers.ch\/wp-content\/uploads\/2021\/07\/post-exchange-20161.jpg?fit=710%2C315&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8sxjX-qA","jetpack-related-posts":[],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/posts\/1648","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/comments?post=1648"}],"version-history":[{"count":3,"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/posts\/1648\/revisions"}],"predecessor-version":[{"id":1651,"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/posts\/1648\/revisions\/1651"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/media\/1290"}],"wp:attachment":[{"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/media?parent=1648"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/categories?post=1648"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/tags?post=1648"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}