0

I guess there are two issues.

  1. The Else statment outputs nothing.
  2. The get-ciminstance below Write-Host "Currently Installed Dell Update Versions:", does not display until the end of the script right above Write-Host "Complete"
[string[]] $DellUpdate_GUIDS = @(
#Dell Update    4.1.0
"{944FB5B0-9588-45FD-ABE8-73FC879801ED}",
#Dell SupportAssist OS Recovery Plugin for Dell Update 5.4.1.14954
"{900D0BCD-0B86-4DAA-B639-89BE70449569}"
)

#Show currently installed Dell Update Version(s)
Write-Host "Currently Installed Dell Update Versions:" 
Get-CimInstance win32_product -filter "name like 'Dell%Update'" | Select-Object name,IdentifyingNumber,Version 

[string[]] $Installed = (Get-CimInstance win32_product -filter "name like 'Dell%Update'" | Select-Object -expand IdentifyingNumber)

foreach($Installed_GUID in $Installed)
{
    if ($DellUpdate_GUIDS -contains $Installed_GUID)
    {
        Write-Host "There is a match!"
    }
else
    {
        Write-Host "Did NOT find $Installed_GUID in Dell Update GUIDS Array"
    }
}
Write-Host "Complete"
My9to5
  • 93
  • 8

1 Answers1

2

Couple of things here that I'd like to point out.

First - you don't have to call Get-CimInstance twice. You can call it once and save it as an object and proceed parsing this object :)

Second - you probably need name like 'Dell%Update%' filter, as sometimes Dell Update is named Dell Update for Windows XXXX or in enterprise environments Dell Command | Update for Windows XXXX

So, after little refactor your script might look like:

[string[]] $DellUpdate_GUIDS = @(
#Dell Update    4.1.0
"{944FB5B0-9588-45FD-ABE8-73FC879801ED}",
#Dell SupportAssist OS Recovery Plugin for Dell Update 5.4.1.14954
"{900D0BCD-0B86-4DAA-B639-89BE70449569}"
)

$cimInstalled = (Get-CimInstance win32_product -filter "name like 'Dell%Update%'" | Select-Object Name, IdentifyingNumber, Version)
#Show currently installed Dell Update Version(s)
Write-Host "Currently Installed Dell Update Versions: $([string]::Join(", ", $cimInstalled.Name))" 

[string[]] $Installed = ($cimInstalled | Select-Object -expand IdentifyingNumber)

foreach ($Installed_GUID in $Installed) 
    if ($DellUpdate_GUIDS -contains $Installed_GUID) {
        Write-Host "There is a match!"
    }
    else {
        Write-Host "Did NOT find $Installed_GUID in Dell Update GUIDS Array"
    }
}
Write-Host "Complete"

This way it gives me output:

Currently Installed Dell Update Versions: Dell Command | Update for Windows 10
Did NOT find {4CCADC13-F3AE-454F-B724-33F6D4E52022} in Dell Update GUIDS Array
Complete
Karolina Ochlik
  • 908
  • 6
  • 8