I am not sure which of the cmdlets is producing the excessive width or if any are … perhaps something else is at work here.
I currently am using Get-ChildItem -Path L:\ | Out-String assigned to a variable to capture the contents of a directory.
That variable is used with -Body from the Send-MailMessage cmdlet
But when the output arrives in the e-mail the output is very wide and the columns like MODE, LastWriteTime, and such scrunched together.
Mode LastWriteTime Length Name
---- ------------- ------ ---- (these don’t line up under the heading)
-a— 10/30/2020 12:31AM RM.0.FTF.DBPART100.2020102513090000009 (then lots of space this way ->)
76 (and some lines wrap and have a number which I don’t know what it is)
-a— 10/30/2020 12:32 AM TM.0.FIF.DBPART100.2020102513110000009 (then lots of space this way ->)
(and some lines wrap and don’t have this extra number)
With Out-String I have tried a few parameters like -Width 80 but that does something odd. Using the first example line from above (the RM) file becomes:
-a— 10/30/2020 12:31AM RM.0.FTF.DBPART100.20201025130900000… (then lots of space this way ->)
76 09 (why does the 09 appear on the right instead of left like 09 76)
(if I arrow-right to the end of the line, the cursor wraps normally and proceeds to the 76 on the next line)
Anyway … Can this be formatted better? Or can something produce the output you get with the old dir.exe
Kind regards to all