Advice on formatting table column

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Graham Beer Graham Beer 3 months, 3 weeks ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #42127
    Profile photo of Graham Beer
    Graham Beer
    Participant

    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
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    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
    Profile photo of Graham Beer
    Graham Beer
    Participant

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

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.