PowerShell output into text file (File Formating Issue)

~OSD~ 2,201 Reputation points
2022-12-30T19:26:54.007+00:00

Hi,

I am using PowerShell to get the information about the Disk Volumes and saving the output into text file.
The saved text file is not well formatted and I am wondering if there is a way to improve the file formatting of the saved file?

Question1 : Possible to improve file formatting of the saved text file?

Question 2: Instead of text file, is it possible to generate a well formatted HTML or PDF file?

Here is what I am doing currently:

275095-image.png

And the saved output is as follows:

275028-image.png

Windows for business Windows Server User experience PowerShell
Windows for business Windows Client for IT Pros User experience Other
{count} votes

Accepted answer
  1. Rich Matheisen 47,901 Reputation points
    2023-01-01T15:52:43.42+00:00

    If you want HTML, it takes a bit more work:

    $props = "DriveLetter", "FriendlyName", "FileSystemType", "DriveType", "HealthStatus", "OperationalStatus", "SizeRemaining", "Size"  
    get-volume |   
        Select-Object $props |  
            ConvertTo-Html |   
                Out-File c:\junk\gv.htm  
    # optional -- if you want to see the web page right away  
    c:\junk\gv.htm  
    

1 additional answer

Sort by: Most helpful
  1. Rich Matheisen 47,901 Reputation points
    2022-12-30T19:46:41.073+00:00

    It looks to me as if the problem lies with choice of fonts used to display the text. Try using a font that uses a fixed pitch (i.e., all characters are of the same width).


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.