Input width ends with ...}

Tagged: 

This topic contains 7 replies, has 4 voices, and was last updated by Profile photo of Dan Potter Dan Potter 2 months, 2 weeks ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #46777
    Profile photo of Jules Wale
    Jules Wale
    Participant

    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

    #46781
    Profile photo of Don Jones
    Don Jones
    Keymaster

    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?

    #46783
    Profile photo of Dan Potter
    Dan Potter
    Participant

    select -expandproperty proxyaddresses

    #46785
    Profile photo of Dan Potter
    Dan Potter
    Participant

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

    #46787
    Profile photo of Craig Duff
    Craig Duff
    Participant

    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.

    #46915
    Profile photo of Jules Wale
    Jules Wale
    Participant

    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

    #46931
    Profile photo of Dan Potter
    Dan Potter
    Participant
    get-aduser me -Properties proxyaddresses | select @{n='x500';e={$_.proxyaddresses -match 'x500'}},samaccountname
    
    #46933
    Profile photo of Dan Potter
    Dan Potter
    Participant

    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
    
    
    ''
    }
    
    
Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.