I have been searching for an answer and I thought I saw the answer on one of the Microsoft Virtual Academy videos for Powershell. I want to try do a Get-ADUser showing several fields in a table format. The issue I am having is trying to format the ProxyAddresses attribute to list one address per line with the ProxyAddresses as the header. Ideally, I would like to see the following
The part I saw on MVA was Jason using pipes to eventually get this type of output. Unfortunately, I do not have the time to go through all 8 hrs of the videos again to find it. <smile> Thanks for the help!
I don’t have an AD environment up and running at the moment to test this, so I’ve simulated an object with a Name and ProxyAddresses property, and formatted it the way you mentioned by a combination of Select-Object (with a constructed property) and Format-Table -Wrap. (You can also throw in the -AutoSize parameter to Format-Table, if you prefer.)
Did Jason do something different when he was doing the MVA video that got it to do the same thing on the same line? I assume I can put everything in the @() block with semicolons replacing the variable. But I swear there was a single line he did this with.
Beats me, I don’t have those videos memorized. I separate things onto multiple lines to make them more readable, but technically, there’s nothing there that you couldn’t jam into a single line. For example:
Personally, I find that kind of one-liner to be an eyesore, and I never put them into my scripts. I occasionally do that sort of thing at the console (interactively), but that’s about it.