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 6 months ago.

  • Author
    Posts
  • #67020

    Ritmo2k
    Participant

    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
    Participant

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

  • #67036

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

      Ritmo2k
      Participant

      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
    Participant

    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.