0

I'm struggling to get a proper output, without any spaces and breaks. However, it automatically seems to add breaks and spaces. I'm using the code below.

Get-Content U:\Syn.txt | % {get-aduser -server blabla.com -f "proxyaddresses -like '*$_*'" -Properties userprincipalname,displayname,enabled,description,proxyaddresses,primarygroup} | fl userprincipalname, proxyaddresses, displayname, enabled, description, PrimaryGroup | out-file U:\output.txt

Below is the output (confidential data has been replaced with "xxxx") I get in return. Please pay attention to the "proxyaddresses" attribute, in which breaks and spaces can be found, due to its lengthy output. See the attachment for the resulted output I get.

userprincipalname : xxxx@xxx.com proxyaddresses : {x500:/o=ExchangeLabs/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=3621dc31ee084f5a91fa8961a2c54033-HLD1LOD, X500:/o=BSH/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=4b48b969c084441c94b2e75d7ebe53dd-xxxxxxxx, sip:xxxx@xxx.com, SMTP:xxxx@xxx.com} displayname : xxxx@xxx.com enabled : True description : xxxx xxxx PrimaryGroup : CN=Domain Users,CN=Users,DC=xxxx,DC=xxxx,DC=xxxx,DC=com

Requested Result: My intention is to receive an output without these breaks and spaces. is there an easy way without too much of a coding, that would help me to return an output without breaks and spaces in a single line?

Many thanks in advance for your support.

Export with breaks and spaces

  • https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/out-file?view=powershell-7.3#example-5-set-file-output-width-for-entire-scope Does example 5 here help? This shows how you can set the line width to a very large value and avoid unwanted line breaks – slothrop Jan 31 '23 at 22:12
  • 1
    Replace `fl` with `Select-Object` – Mathias R. Jessen Jan 31 '23 at 23:13
  • In short: use `Out-File` with a sufficiently large `-Width` argument. See the linked duplicate for details. However, note that the output format is meant _for display_ (the human observer) rather than for _programmatic processing_. Consider using a _structured_ text format instead, such as JSON or CSV. – mklement0 Feb 01 '23 at 03:05

0 Answers0