ConvertTo-HTML cmdlet

Welcome Forums General PowerShell Q&A ConvertTo-HTML cmdlet

This topic contains 2 replies, has 2 voices, and was last updated by

4 years, 10 months ago.

  • Author
  • #13891

    Points: 0
    Rank: Member

    hi everyone,

    get-process |
    Select-Object name,Description,VM |
    ConvertTo-Html|Format-Table name,description,@{n='VM(MB)';e={$PSItem.VM / 1MB -as [int]};formatstring='f2'; align='right'} |
    Out-File C:\Users\Administrator\Desktop\Powershell\process3.html

    when i run this script it runs without errors but its not what i expected i want to format the VM column as mention in the script
    but i get the output as default formatting

    Note:-when i run this script without ConverTo-HTML the Formatting is applied as in the script

    is there any way of solving this plz help

    Thanks !!!

  • #13893

    Points: 1,759
    Helping HandTeam Member
    Rank: Community Hero

    The output of Format-* cmdlets cannot be consumed by anything but Out-File, Out-String, Out-Printer, and Out-Host. This is a common mistake, as described in "The Big Book of PowerShell Gotchas" ( I suggest reviewing that (it's a free book).

    Consider using Select-Object instead. You will need to remove the FormatString and Align directives, as Select-Object does not support those.

  • #13894

    Points: 0
    Rank: Member

    Thanks for the help and recommendation

    Have a nice day

The topic ‘ConvertTo-HTML cmdlet’ is closed to new replies.