Excessive Width From Get-ChildItem or Out-String or Send-MailMessage

Welcome Forums General PowerShell Q&A Excessive Width From Get-ChildItem or Out-String or Send-MailMessage

Viewing 5 reply threads
  • Author
    Posts
    • #268877
      Participant
      Topics: 2
      Replies: 5
      Points: 29
      Rank: Member

      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.

      Example:

      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

    • #268883
      Participant
      Topics: 17
      Replies: 1869
      Points: 3,631
      Helping Hand
      Rank: Community Hero

      When formatting for an email, leverage HTML. There is an ebook in the Free Resources that talks about reporting in HTML. The general idea:

    • #268886
      Participant
      Topics: 2
      Replies: 5
      Points: 29
      Rank: Member

      Thanks Rob.  I will give that a try shortly.  Just wanted to report, I figured out what the extra number was.  Because of the scrunching the 76 is actually part of the Length i.e. file size which I unfortunately did not include in my examples above.  The file size is:    121,396,043,776

    • #268895
      Participant
      Topics: 2
      Replies: 5
      Points: 29
      Rank: Member

      Thanks Rob, this worked nicely.  I will use that source you referenced to see if it has info on making the output sorted by date.

    • #268916
      Participant
      Topics: 17
      Replies: 1869
      Points: 3,631
      Helping Hand
      Rank: Community Hero
    • #269144
      Participant
      Topics: 2
      Replies: 5
      Points: 29
      Rank: Member

      Ok.  Show off.  🙂  LOL.  But, really, thank you.

Viewing 5 reply threads
  • You must be logged in to reply to this topic.