Wanting stmp old and new email address from proxyAddresses AD attribute

62 Views Asked by At

The following script works, but if I put an old email address that a user had it doesn't provide data. I want to show all the new and current emails address with me providing an old email address.

Here is my GitHub where to script is located.

https://github.com/On3n3xus/PowerShell/blob/main/ProxyAddresses

I'm trying to get all the ProxyAddresses data, if I only have an old email address.

Example:

$user = Get-ADUser -Filter { EmailAddress -eq "[email protected]" } -Properties proxyAddresses
$user.proxyAddresses
2

There are 2 best solutions below

1
Martin Iszac On

See: Getting the proxyaddresses attribute of users

You need to search the proxyAddresses attribute.

$User = Get-ADUser -Filter { proxyAddresses -like "*${EmailAddress}*" } -Properties proxyAddresses, SamAccountName
0
On3N3xus On

I had to add SMTP in the email address loop.

$User = Get-ADUser -Filter "proxyAddresses -like 'SMTP:*$($EmailAddress)*'" -Properties proxyAddresses, SamAccountName

It worked.