Advice on formatting table column

Welcome Forums General PowerShell Q&A Advice on formatting table column

Viewing 2 reply threads
  • Author
    Posts
    • #42127
      Participant
      Topics: 37
      Replies: 143
      Points: 0
      Rank: Member

      Hi,

      I'm writing a script to give a site overview of configuration manager. By doing the below script :

      
      $Site = 
          Get-CimInstance -Namespace 'root\SMS\site_***' -ClassName SMS_SCI_SysResUse |
             select -Property NetworkOSPath -ExpandProperty RoleName |
             Group -property NetworkOSPath -AsHashTable -AsString 
      
      $column1 = @{expression="name"; width=25; label="Server"; alignment="left"}
      $column2 = @{expression="Value"; width=80; label="Role Types"; alignment="right"}
      
      
      $site | Format-Table -Wrap $column1, $column2
      
      

      It works as it should apart from a small display niggle ! Below is a line of output:

      \\A_Server {SMS SQL Server, SMS Component Server, SMS Distribution Point, SMS Site
      Server...}

      As you can see, if the Role Types column has more than 4 roles (Like our primary server does), it stops with ..}

      I'm trying to achieve the server name on the left, and on the right all the roles being shown. Then onto the next server and so on.

      I've been playing for a while and can't seem to get the desired result. Would anyone have any ideas ? (Thanks !)

    • #42131
      Member
      Topics: 9
      Replies: 2322
      Points: 0
      Rank: Member

      Maybe try setting your $column2 to this:

      $column2 = @{expression={ $_.Value -join ', ' }; width=80; label="Role Types"; alignment="right"}
      

      Doing the -join instead of leaving it as an array might help.

    • #42204
      Participant
      Topics: 37
      Replies: 143
      Points: 0
      Rank: Member

      Dave, you are a genius ! Thank you, worked a treat.

Viewing 2 reply threads
  • The topic ‘Advice on formatting table column’ is closed to new replies.