Author Posts

July 13, 2016 at 4:31 pm

The code is:

Get-ADUser -SearchBase “OU=MovedUsers,DC=Domain,DC=local” -Filter * -Properties SamAccountName,proxyAddresses | Select-Object SamAccountName,proxyAddresses | ft SamAccountName,proxyAddresses -Wrap -autosize > C:\Scripts\X500Export13072016.txt

At the end of each line i get cn=Recipients/cn=nightshift02...}

How do I increase the width to allow all the data to be displayed.

Many Thanks

Jules

July 13, 2016 at 4:36 pm

That's because what you're getting back includes collections of objects, and when turning those into text PowerShell can only display so many, so it adds the ... at the end to indicate it ran out of room. Your problem is that you've got one property which is just a single value, and another property which is the collection. Since Format-Table has a limited amount of intelligence for dealing with that, you need to take it out of the equation.

What would you LIKE the output to look like?

July 13, 2016 at 4:37 pm

select -expandproperty proxyaddresses

July 13, 2016 at 4:41 pm

get-aduser me -Properties proxyaddresses | select @{n='proxies';e={($_ | select -ExpandProperty proxyaddresses) -join ";"}},samaccountname |fl

July 13, 2016 at 4:42 pm

You've got two issues. One Format-Table auto width is limited to the console buffer width. See the explaination and work around here: https://poshoholic.com/2010/11/11/powershell-quick-tip-creating-wide-tables-with-powershell/

Two, the braces are caused by the fact that proxyAddresses is a multivalued field. There are several ways to deal with this.

Get-ADUser #...# | Select-Object SamAccountName,@{'Name'='addresses';'Expression'={$_.ProxyAddresses -join ','}} | FT #...

That way joins the proxyaddresses with a comma.

Just as an aside, I might consider just using Export-Csv instead of the column width thing. That's a good format and Excel a good tool for viewing the tabular data.

July 14, 2016 at 8:11 am

Hi

Thank you for your replies.

If I use

Get-ADUser -SearchBase “OU=MovedUsers,DC=Domain,DC=local” -Filter * -Properties proxyaddresses | select @{n='proxies';e={($_ | select -ExpandProperty proxyaddresses) -join ";"}},samaccountname |fl

That lists all the addresses. What I try to do is to file that is formated like this:

User1, x500:/o=First Organization/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=User1279
User1, x500:/o=First Organization/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=User1869
User2, x500:/o=First Organization/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=User2324
User2, x500:/o=First Organization/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=User2123
User3, x500:/o=First Organization/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=User3789
User3, x500:/o=First Organization/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=User3951
ETC
ETC

This way I can import the X500 addresses into the new Active Directory in a different forest.

Is this possible? If so how do I format that?

THanks

Jules

July 14, 2016 at 11:47 am

get-aduser me -Properties proxyaddresses | select @{n='x500';e={$_.proxyaddresses -match 'x500'}},samaccountname

July 14, 2016 at 11:52 am

For learning purposes.


$accounts = get-aduser -Filter {anr -eq 'x500'} -Properties proxyaddresses |select -first 10

foreach($account in $accounts){

$account.proxyaddresses -match 'x500'
$account.samaccountname


''
}