Hashtable driving me mad.

Welcome Forums General PowerShell Q&A Hashtable driving me mad.

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

1 year, 9 months ago.

  • Author
  • #70978

    Points: 5
    Rank: Member


    Please can someone help, for some reason when i run the following code to output values in a hashtable, the output is being grouped, but if i remove the 4th item in the hashtable, the output is in a list format.

    I need the output for the 4 items to be in list not grouped.

    Foreach($Vm in $WAPVMs){
    Get-WAPackVM -Name $VM.Name |  Select-Object Name, @{Name=“CPU”;Expression={$_.CPUCount}},
                                                                 @{Name=“DiskSzie”;Expression={$_.TotalSize / 1GB}},

    OutPut with 4 items:

    Name     : ServerName
    CPU      : 2
    Memory   : 4096
    DiskSzie : 14.919921875
    OS       : Windows Server 2012 R2 Standard

    Output with 3 Items

    Name                CPU Memory      DiskSzie
    ----                --- ------      --------
    ServeName     2   8192 30.3701171875   14.4

    What am i doing wrong?



  • #70979

    Points: 2
    Rank: Member

    Nothing at all. By default PowerShell displays objects with 4 or fewer properties as a table, 5 or more in a list. Without doing more advanced stuff, you can just pipe the output of you select-object command to Format-List to get the results you want.

The topic ‘Hashtable driving me mad.’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort