Answered by:
Sam account from legacyExchangeDN

Question
-
I've been given a list of users with only their legacyexchangeDN. Is there a way with Powershell to get the SAM account from this? I tried get-mailbox where legacyexchangedn -eq "xxx" but it seems that is not a searchable value.Thursday, May 16, 2013 5:07 PM
Answers
-
It seems to be in the list of filterable properties: http://blogs.technet.com/b/evand/archive/2007/02/19/filterable-properties-in-exchange-2007-rtm.aspx#Mailbox
This worked for me against one legacyexchangedn:
Get-Mailbox -Filter {LegacyExchangeDN -eq "/o=Org/ou=AdminGroup/cn=Recipients/cn=alias"} | Select SamAccountName
Assuming that works then it should just be a case of getting your DNs into a variable somehow (eg. import-csv) and looping through them.
I hope this helps,
Mark.
Thursday, May 16, 2013 5:27 PM -
On Thu, 16 May 2013 17:27:18 +0000, - Mark - wrote:>>>It seems to be in the list of filterable properties: http://blogs.technet.com/b/evand/archive/2007/02/19/filterable-properties-in-exchange-2007-rtm.aspx#Mailbox>>This worked for me against one legacyexchangedn:>>Get-Mailbox -Filter {LegacyExchangeDN -eq "/o=Org/ou=AdminGroup/cn=Recipients/cn=alias"} | Select SamAccountName>>Assuming that works then it should just be a case of getting your DNs into a variable somehow (eg. import-csv) and looping through them.No need even for the filter.get-mailbox -identity "/o=Org/ou=AdminGroup/cn=Recipients/cn=alias" isall you need.---Rich MatheisenMCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVP- Marked as answer by DPFY Friday, May 17, 2013 11:56 AM
Friday, May 17, 2013 1:40 AM
All replies
-
It seems to be in the list of filterable properties: http://blogs.technet.com/b/evand/archive/2007/02/19/filterable-properties-in-exchange-2007-rtm.aspx#Mailbox
This worked for me against one legacyexchangedn:
Get-Mailbox -Filter {LegacyExchangeDN -eq "/o=Org/ou=AdminGroup/cn=Recipients/cn=alias"} | Select SamAccountName
Assuming that works then it should just be a case of getting your DNs into a variable somehow (eg. import-csv) and looping through them.
I hope this helps,
Mark.
Thursday, May 16, 2013 5:27 PM -
Thanks, I'll give it a try tomorrow.Thursday, May 16, 2013 5:46 PM
-
On Thu, 16 May 2013 17:27:18 +0000, - Mark - wrote:>>>It seems to be in the list of filterable properties: http://blogs.technet.com/b/evand/archive/2007/02/19/filterable-properties-in-exchange-2007-rtm.aspx#Mailbox>>This worked for me against one legacyexchangedn:>>Get-Mailbox -Filter {LegacyExchangeDN -eq "/o=Org/ou=AdminGroup/cn=Recipients/cn=alias"} | Select SamAccountName>>Assuming that works then it should just be a case of getting your DNs into a variable somehow (eg. import-csv) and looping through them.No need even for the filter.get-mailbox -identity "/o=Org/ou=AdminGroup/cn=Recipients/cn=alias" isall you need.---Rich MatheisenMCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVP- Marked as answer by DPFY Friday, May 17, 2013 11:56 AM
Friday, May 17, 2013 1:40 AM -
Nice Rich, you learn something new every day ... or get reminded of something you'd forgotten ;)
So if you can use the LegacyExchangeDN with the -identity parameter and -identity is positional you could lose that too and just go with: get-mailbox "/o=Org/ou=AdminGroup/cn=Recipients/cn=alias"
Mark.
Friday, May 17, 2013 9:23 AM -
Thanks Rich and Mark, got it working. Thought I had tried the -identity field already but it worked no problems when I tried it today.
- Edited by DPFY Friday, May 17, 2013 11:56 AM spelling
Friday, May 17, 2013 11:55 AM -
On Fri, 17 May 2013 09:23:41 +0000, - Mark - wrote:>Nice Rich, you learn something new every day ... or get reminded of something you'd forgotten ;)>>So if you can use the LegacyExchangeDN with the -identity parameter and -identity is positional you could lose that too and just go with: get-mailbox "/o=Org/ou=AdminGroup/cn=Recipients/cn=alias"That's correct. The "-identity" parameter is the 1st positionalparameter.I just don't like using positional parameters in scripts. Call it"coding style", like having curly braces line up vertically, I guess.:-)---Rich MatheisenMCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVPSaturday, May 18, 2013 2:21 AM