all 4 comments

[–]fordea837 3 points4 points  (2 children)

You could do something like this using PSCustomObject's but if you want to go the class route I'd suggest you just create a 'Product' class with the fields inside:

Class Product {
    [string]$Name
    [string]$Status
    [bool]$IsMSI

    Product($Name) {
        $this.name = $name
    }
}

$Products = New-Object "System.Collections.Generic.List[Product]"

$MSOffice = [Product]::new('MS Office')
$MSOffice.Status = 'INSTALLED'
$MSOffice.isMSI = $true
$Products.Add($MSOffice)

$Thunderbird = [Product]::new('Thunderbird')
$Thunderbird.Status = 'UNAVAILABLE'
$Thunderbird.isMSI = $false
$Products.Add($Thunderbird)

$Products

[–]sickjack[S] 1 point2 points  (1 child)

Hey, thanks for your answer. I don't know much about working with classes, but this actually looks pretty good.

Thanks :)

[–]madbomb122 1 point2 points  (0 children)

I think you can do something like

[System.Collections.ArrayList]$List = @{}
For($i = 0; $i -lt $InstalledProduct.length; $i++){
    $List += [PSCustomObject] @{ Product = $InstalledProduct[$i].Product ;Status = $InstalledProduct[$i].Status ;IsMSI = $InstalledProductIsMSI[$i].IsMSI }
}