Working with the proxyAddresses Attribute

Hey,

Just wanted to share my recent experience with working with the proxyAddresses attribute.

Disclaimer: I am definitely not an expert with PowerShell and I mainly just script to the point of what works for me. I just wanted to compile my experience with proxyAddresses into one place.

Working with proxyAddresses from within a script module:

For my particular case I needed to do two things

  • Delete an existing email address
  • Append two new email addresses.
    • One as a primary
    • One as an alias

Why did I need to do this?

  • I am currently working on allowing users to have their names changed. When a user name changes we are mandating that everything related to the user must change. We will allow them to keep an alias of their old email for a short period of time.

This was done using the following code:

$Request.PutEx($Constants.ADS_PROPERTY_DELETE, "proxyAddresses", "$currentEmailSMTP")
$Request.PutEx($Constants.ADS_PROPERTY_APPEND, "proxyAddresses", @("$newEmailSMTP","$newEmailSMTPAlias"))

The variables used ($currentEmailSMTP, $newEmailSMTP, $newEmailSMTPAlias) were all generated on event Modify.

I am not exactly sure what "$Constants" does. I do not explicitly setting this. Perhaps someone can fill in this piece. It may not be required. But this is what worked for me.

Working with proxyAddresses from within a PowerShell script:

For my particular case, I needed to clean up an alias email address. The alias needs to be cleaned up one month after a name change is performed. We elected to handle this outside of the ARS because we have other scripts running that submit tickets to our helpdesk. We elected to use these scripts to do the cleanup of the alias. I figure I could probably handle this inside of ARS, but I don't know how to schedule something to occur at a later date.

A few things to note:

  • The alias address will be a hardcoded value that we already know.
  • The target user will be a hardcoded value that we already know.

$user = "GUID of some user"
$removeEmailSMTPAlias = "smtp:john.smith@example.com"
$getUser = Get-QADUser -identity $user -proxy

set-qaduser -identity "$user" -objectAttributes @{ProxyAddresses=@{Delete=@("$removeEmailSMTPAlias")}}

Update - Using Add-QADProxyAddress and Remove-QADProxyAddress

After posting this  mentioned the two cmdlets mentioned above! They make life so much easier!!

You can get some good examples running the following command(s):

Get-Help Add-QADProxyAddress -Examples
Get-Help Remove-QADProxyAddress -Examples

Example of using it

$user = "john.smith"
$getUser = Get-QADUser -identity $user -proxy

$getUser | Remove-QADProxyAddress -Pattern "smtp:john.smith2@example.com"
$getUser | Add-QADProxyAddress -Address "smtp:john.smith3j@example.com"

References:

Cheers,

Todd

Parents Reply
  • These commands make life SO much easier!

    I will update my post to include these examples. I never once saw them mentioned in the forums.

    Thank you  for mentioning them!

    The Get-Help Add-QADProxyAddress/Remove-QADProxyAddress is definitely helpful! Thank you for pointing out needing to feed it a user identity.

Children