dsccommunity / SharePointDsc

The SharePointDsc PowerShell module provides DSC resources that can be used to deploy and manage a SharePoint farm
MIT License
245 stars 107 forks source link

[SPInstallPrereqs] Multiple instances of the VC++ Redist causes issues #1410

Closed ykuijs closed 1 year ago

ykuijs commented 1 year ago

Problem description

Add/remove programs on a server shows this: image

When checking $installeditems in SPInstallPrereqs, this results in: image Here both entries have the same bundleupgradecode.

In the resource code, this is done:

"BundleUpgradeCode"
{
    $installedItem = $InstalledItems | Where-Object -FilterScript {
        $null -ne $_.BundleUpgradeCode -and ($null -eq ($_.BundleUpgradeCode.Trim() | Compare-Object $itemToCheck.SearchValue))
    }
}

However, here $installedItem contains 2 items instead of the expected 1, which is causing this code to fail:

[System.Version]$installedVersion = $installedItem.DisplayVersion 

and throwing this error:

Cannot convert the "System.Object[]" value of type "System.Object[]" to type "System.Version".

  • CategoryInfo : MetadataError: (:) [], CimException
  • FullyQualifiedErrorId : RuntimeException
  • PSComputerName :

Verbose logs

Cannot convert the "System.Object[]" value of type "System.Object[]" to type "System.Version".
    + CategoryInfo          : MetadataError: (:) [], CimException
    + FullyQualifiedErrorId : RuntimeException
    + PSComputerName        : <servername>

DSC configuration

N/A

Suggested solution

Make sure only one component is returned

SharePoint version and build

SP2019

Operating system the target node is running

Windows Server 2016

PowerShell version and build the target node is running

5.1

SharePointDsc version

v5.2