none
Modify customobject to get certain output RRS feed

  • Question

  • Hi,

    I have created an object $Overview which consists of the following:
    SoftwareName  ComputersOnWhichThisSoftware
    ------------  -----------------------------
    Acrobat       {pc02,pc03}
    Z-Zip          {pc01,pc02,pc03}

    The object property of this $Overview object is TypeName: System.Management.Automation.PSCustomObject

    How could I modify it so I get
    computername Software
    ------------ ---------------
    pc01         7-Zip
    pc02          Acrobat,Z-zip

    Please advise.
    J.



    Jan Hoedt

    Wednesday, January 25, 2017 5:08 PM

Answers

  • You always ask the wrong question three times before you clearly state the issue. Hmmm.

    Select @{n='Computers';e={$_.ComputersOnWhichThisSoftware -join '|'}}


    \_(ツ)_/

    • Marked as answer by janhoedt Thursday, January 26, 2017 7:52 PM
    Wednesday, January 25, 2017 9:00 PM

All replies

  • Have you considered using the correct name when you create the object?

    \_(ツ)_/

    Wednesday, January 25, 2017 5:33 PM
  • Almost there. How do I get the ... away in the pscustomobject (see below next to pc03)? There is more data but it doesn't show it.

    SoftwareName  ComputersOnWhichThisSoftware
    ------------  -----------------------------
    Acrobat       {pc02,pc03}
    Z-Zip          {pc01,pc02,pc03...}


    Jan Hoedt

    Wednesday, January 25, 2017 7:46 PM
  • Almost there. How do I get the ... away in the pscustomobject (see below next to pc03)? There is more data but it doesn't show it.

    SoftwareName  ComputersOnWhichThisSoftware
    ------------  -----------------------------
    Acrobat       {pc02,pc03}
    Z-Zip          {pc01,pc02,pc03...}


    Jan Hoedt

    Format-List or Format-Table -Wrap


    \_(ツ)_/

    Wednesday, January 25, 2017 8:05 PM
  • Thanks, is there also a way to get rid of the {}?

    SoftwareName  ComputersOnWhichThisSoftware
    ------------  -----------------------------
    Acrobat       {pc02,pc03}
    Z-Zip          {pc01,pc02,pc03...


    Jan Hoedt

    Wednesday, January 25, 2017 8:41 PM
  • You always ask the wrong question three times before you clearly state the issue. Hmmm.

    Select @{n='Computers';e={$_.ComputersOnWhichThisSoftware -join '|'}}


    \_(ツ)_/

    • Marked as answer by janhoedt Thursday, January 26, 2017 7:52 PM
    Wednesday, January 25, 2017 9:00 PM
  • That works, nice!

    If I would need to change the names within the ComputersOnWhichThisSoftware, how should I approach that?

    so {pc01 - PROD,pc02 - TST,pc03 - TST...}  

    I'd like to filter only pc01 so would need to .split(' - ')[0] for each item.


    Jan Hoedt


    • Edited by janhoedt Thursday, January 26, 2017 8:35 AM update
    Thursday, January 26, 2017 8:22 AM
  • The answer to my question: you simply extract the data in a new pscustomobject.

    Jan Hoedt

    Thursday, January 26, 2017 7:53 PM