powershell to csv getting columns

Hi all,

For my internship I need to write a script. My script is: Get-ADUser -Filter * -Properties * | select Name,whenCreated, Description, whenchanged, Lastlogondate, LastBadPasswordAttempt, BadlogonCount, LockedOut, Enabled |export-csv c:\informatie-user-csv.csv.

how can I get all these properties in a different columns in my csv-file?




What’s wrong with the answeres you’ve got there? You didn’t even replied to them.

The export cmdlet send raw data to a file, they do not format them for you.

That Export-Csv cmdlet, by default send the data in a column format, but it will not show as a table in a text or other file reader.
What you will seem is a flat file, with double quotes and common separated. This is basic PS intro level stuff.

You can see the table / column format by simply using the Import-Csv cmdlet and see the auto-formatted table on your screen. It’s the PS automatic formatters that is doing this for screen only display, and it will not do that for output. You need to do that, yourself in code or sending to screen and clip from there to paste in a file, .txt, Word, etc.

Being new to PS is fine, but it is vital that you expend the effort to get up to speed on it. Using all the no-cost / free video …

https://www.youtube.com/results?search_query=beginning+powershell https://www.youtube.com/results?search_query=beginning+export+formatting+powershell

…and eBook resource available all over the web. Even on this site, just click the ‘Free Resources’ link in the left navigation pane or see these Q & A’s.

https://www.reddit.com/r/PowerShell/comments/ar6cvt/powershell_in_depth_second_edition/egmlpom/?context=3 https://www.reddit.com/r/PowerShell/comments/afqmmw/i_want_to_help_my_husband_advance_his_powershell/ee3k6p6/?context=3

And this…

https://docs.microsoft.com/en-us/powershell https://blogs.msmvps.com/richardsiddaway/2019/02/21/the-source-of-powershell-cmdlets