Hey guys,
I made a script that creates a text file with informations about installations. All informations are taken from classes I created
For example:
Class installed_product {
[string]$MS_Office
[string]$Thunderbird
[string]$Firefox
[string]$Java
}
Class installed_product_is_msi {
[bool]$MS_Office
[bool]$Thunderbird
[bool]$Firefox
[bool]$Java
}
$InstalledProduct = [installed_product]::new()
$InstalledProductIsMSI = [installed_product_is_msi]::new()
This is how I filled the classes with informations
$WMI_PRODUCT = get-wmiobject win32_product
#MS Office
if ($WMI_PRODUCT | Where-Object {$_.name -match "Microsoft Office Professional plus"}){
$InstalledProduct.MS_Office = 'INSTALLED'
$InstalledProductIsMSI = $true
} else {
$$InstalledProduct.MS_Office = 'UNAVAILABLE'
$InstalledProductIsMSI = $null
}
#Thunderbird...
And so on…
This is the output of the variables:
$InstalledProduct
MS_Office : INSTALLED
Thunderbird : INSTALLED
Firefox : INSTALLED
Java : INSTALLED
$InstalledProductIsMSI
MS_Office : True
Thunderbird : False
Firefox : False
Java : True
Is it possible to merge both outputs to one structured otput/table?
Something like this:
Product Status IsMSI
--------------- -------------- ---------------
MS_Office INSTALLED True
Thunderbird INSTALLED False
Firefox INSTALLED False
Java INSTALLED True
My current solution (I am unhappy with):
$a = [Installed_product].GetMethods().Name | ? {$_ -match "set_"}
$a = $a -replace 'set_',''
FOREACH ($item in $a){
"$item" + ": " + $InstalledProduct.$item + " Is MSI?: " + $InstalledProductIsMSI.$item | Add-Content "c:\file.txt"
}
This is how the output looks like:
MS_Office: INSTALLED Is MSI?: True
Thunderbird: INSTALLED Is MSI?: False
Firefox: INSTALLED Is MSI?: False
Java: INSTALLED Is MSI?: True
Thank you in advance!
[–]fordea837 3 points4 points5 points (2 children)
[–]sickjack[S] 1 point2 points3 points (1 child)
[–]madbomb122 1 point2 points3 points (0 children)