Private/Get-RequiredVcRedistUpdatesFromIntune.ps1

function Get-RequiredVcRedistUpdatesFromIntune {
    <#
        .SYNOPSIS
            Determines which Visual C++ Redistributable applications in Intune require an update based on a provided VcList.

        .DESCRIPTION
            The Get-RequiredVcRedistUpdatesFromIntune function compares the versions of Microsoft Visual C++ Redistributable Win32 applications currently present in Intune with those specified in a provided VcList object.
            It outputs objects indicating whether an update is required for each matched application.

        .PARAMETER VcList
            A PSObject containing a list of Visual C++ Redistributable packages, typically generated by Save-VcRedist.
            Each object in the list should include at least 'PackageId' and 'Version' properties.

        .INPUTS
            System.Management.Automation.PSObject
            Accepts a VcList object from the pipeline.

        .OUTPUTS
            PSCustomObject
            Outputs an object for each matched application with the following properties:
                - AppId: The Intune application ID.
                - IntuneVersion: The version currently in Intune.
                - UpdateVersion: The version available in the VcList.
                - UpdateRequired: Boolean indicating if an update is required.

        .EXAMPLE
            $vcList = Save-VcRedist
            Get-RequiredVcRedistUpdatesFromIntune -VcList $vcList

            Compares the Visual C++ Redistributable applications in Intune with those in $vcList and outputs which require updates.

        .NOTES
            Requires the Get-IntuneWin32App cmdlet to retrieve Win32 applications from Intune.
            Only applications with notes containing a 'Guid' property matching a VcList PackageId are considered.
    #>

    [CmdletBinding(SupportsShouldProcess = $false)]
    param (
        [Parameter(
            Mandatory = $true,
            Position = 0,
            ValueFromPipeline,
            HelpMessage = "Pass a VcList object from Save-VcRedist.")]
        [ValidateNotNullOrEmpty()]
        [System.Management.Automation.PSObject] $VcList
    )

    begin {
        # Get the existing VcRedist Win32 applications from Intune
        $ExistingIntuneApps = Get-VcRedistAppsFromIntune -VcList $VcList
    }

    process {
        foreach ($Application in $ExistingIntuneApps) {
            $VcRedist = $VcList | Where-Object { $_.PackageId -eq $Application.packageId }
            if ($null -eq $VcRedist) {
                Write-Verbose -Message "No matching VcRedist found for application with ID: $($Application.Id). Skipping."
                continue
            }
            else {
                $Update = $false
                if ([System.Version]$VcRedist.Version -gt [System.Version]$Application.displayVersion) {
                    $Update = $true
                    Write-Verbose -Message "Update required for $($Application.displayName): $($VcRedist.Version) > $($Application.displayVersion)."
                }
                $Object = [PSCustomObject]@{
                    "AppId"          = $Application.Id
                    "IntuneVersion"  = $Application.displayVersion
                    "UpdateVersion"  = $VcRedist.Version
                    "UpdateRequired" = $Update
                }
                Write-Output -InputObject $Object
            }
        }
    }
}