Formatting the table when using Write-Output in a cmdlet

This topic contains 4 replies, has 3 voices, and was last updated by  Olaf Soyk 1 year, 2 months ago.

  • Author
  • #67020


    When sending PSObjects down the pipeline with only one or two properties, is there a way to force the default display to left align without using another pipeline invocation?

  • #67029

    Olaf Soyk

    Your question is to vague to give a helpful answer ... could you explain that more precicly or show some code example?

  • #67036

    Sam Boutros
    New-Object -TypeName PSObject -Property @{
        ComputerName = $env:COMPUTERNAME
        AdDomain     = $env:USERDOMAIN
    } | Format-Table ComputerName, AdDomain -Auto 
    • #67041


      Hi Sam,
      That was what I was trying to avoid (a pipeline invocation of Format-Table). What I wondered was if there was a means to override the default display of an object by possibly modifying it.

      I can certainly pipe the output the output of the cmdlet to FT if that is the only solution.

      I wonder why the default settings seem to left align output when only one or two fields are present? Seems odd and un-intuitive...

  • #67047

    Olaf Soyk

    Hmmm ... I guess I have an idea of what you're after. I did not use it but I heard of it in this video from Don Jones and Jeffrey Snover Explore Powershell ... the part I mean starts at about 35 minutes

You must be logged in to reply to this topic.