Getting ProxyAddresses from Get-ADuser in Powershell

This one for some reason always get’s me, and it always takes me longer than it should to find the answer… so if nothing else, this post is so I have quick access to the answer. To get the Proxyaddresses from the get-aduser cmdlet we can use the name and expression (or n= and  e=) pieces of Powershell. Proxy addresses cannot be pulled from Powershell directly as they are not a member of that command. The members of any command can be viewed by using the following:

get-aduser | get-member

Where get-aduser is replaced by whatever CmdLet you choose. So, now that we know it is not a member of that command, how do we extract the proxyaddress information from Powershell? …Use the -properties operator and the Name and Expression form to properly format the information.

This gets you the information:

get-aduser myuser -properties proxyaddresses

However, that doesn’t allow you to export that information… when trying the following:

get-aduser myuser -properties proxyaddresses | export-csv test.csv

You get garbage where you’d hope your proxy addresses would be. To resolve this, pull the property, and then call it into your csv:

get-aduser myuser -properties * | select-object name, samaccountname, surname, enabled, @{"name"="proxyaddresses";"expression"={$_.proxyaddresses}} | Export-Csv test.csv

To be clear, following “name=” can be anything you want… it will be the header for the information you are calling. The “expression=” is calling the actual value. $_. is what is allowing you to access the value of “proxyaddresses” in the array. Using this command, you should now have a CSV that can be viewed, or imported to another CMDLet.

Still Learning Powershell? It’s a bit spendy, but as in most things technology, with this book, you get what you pay for.




Comments

  1. Thanks so much for this. Got to you webpage on my first Google search. Saved me huge amount of time trying to figure this out or searching through numerous blogs.

  2. Hello DOn,

    is there a way where we can get a list of all the Exchange on-prem mailboxes that are missing the sip address on them though powershell please? i need this info and it would be great if you can help me with a command to get this information please.

    1. I don’t have an Exchange server to test on anymore, but it seems to me you could probably use something like:

      [code]
      get-aduser myuser -properties * | select-object name, samaccountname, surname, enabled, @{"name"="sipaddress";"expression"={$_.sipaddress}} | Export-Csv test.csv
      [/code]

      Though you would have to verify that the AD property you are after is actually sipaddress and not something else (like sipaddresses, sip-address, etc.)

      Hope this gets you where you need to go!

Leave a Reply

Your email address will not be published. Required fields are marked *