aaronparker / vcredist

Lifecycle management for the Microsoft Visual C++ Redistributables
https://vcredist.com
MIT License
132 stars 17 forks source link

VcMdtApplication cmdlets have not worked for some time now. Last worked in 3.0.273 I believe. #154

Closed BronsonMagnan closed 8 months ago

BronsonMagnan commented 10 months ago

$Path = "X:\Evergreen" Get-VcList | Save-VcRedist -Path "$Path\VcRedist\" $vclist = get-vclist Import-VcMdtApplication -VcList ($vclist) -Path "$Path\VcRedist\" -MdtPath \fabricmdt\FactoryDeployment -Verbose -AppFolder VCRedist3

VERBOSE: Retrieving existing Visual C++ Redistributables from the deployment share Property: 'Path' missing. At C:\Program Files\WindowsPowerShell\Modules\VcRedist\4.1.494\Private\Test-VcListObject.ps1:48 char:21

Update-VcMdtApplication -VcList ($vclist) -Path "$Path\VcRedist\" -MdtPath \fabricmdt\FactoryDeployment -Verbose -AppFolder VCRedist

VERBOSE: Update applications in: DS099:\Applications\VCRedist Property: 'Path' missing. At C:\Program Files\WindowsPowerShell\Modules\VcRedist\4.1.494\Private\Test-VcListObject.ps1:48 char:21

BronsonMagnan commented 10 months ago

Here is the problem code:

        [System.String[]] $RequiredProperties = @("Architecture", "Install", "Name", "ProductCode", `
                "Release", "SilentInstall", "SilentUninstall", "UninstallKey", "URI", "URL", "Version", "Path")
    )

    process {
        foreach ($Item in $VcList) {
            $Members = Get-Member -InputObject $Item -MemberType "NoteProperty"
            $params = @{
                ReferenceObject  = $RequiredProperties
                DifferenceObject = $Members.Name
                PassThru         = $true
                ErrorAction      = "Stop"
            }
            $MissingProperties = Compare-Object @params

            if (-not($missingProperties)) {
                $Result = $true
            }
            else {
                $MissingProperties | ForEach-Object {
                    throw [System.Management.Automation.ValidationMetadataException] "Property: '$_' missing."
                }
            }

vclist objects do not produce a path field, and we are checking for one here.

BronsonMagnan commented 10 months ago

PS X:\Evergreen> $vclist[0]

Name            : Visual C++ Redistributable for Visual Studio 2012 Update 4
ProductCode     : {ca67548a-5ebe-413a-b50c-4b9ceb6d66c6}
Version         : 11.0.61030.0
URL             : https://www.microsoft.com/en-us/download/details.aspx?id=30679
URI             : https://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x64.exe
Release         : 2012
Architecture    : x64
Install         : /install /passive /norestart
SilentInstall   : /quiet /norestart
SilentUninstall : "%ProgramData%\Package Cache\{ca67548a-5ebe-413a-b50c-4b9ceb6d66c6}\vcredist_x64.exe" /uninstall /quiet /norestart
UninstallKey    : 32
BronsonMagnan commented 10 months ago

in update-vcmdtapplication there is this:

        # Make sure that $VcList has the required properties
        if ((Test-VcListObject -VcList $VcList) -ne $true) {
            $Msg = "Required properties not found. Please ensure the output from Save-VcRedist is sent to this function. "
            throw [System.Management.Automation.PropertyNotFoundException]::New($Msg)
        }

but you will never see that useful error message because the error is thrown in Test-VCListObject

BronsonMagnan commented 10 months ago

Changing the invoking code to

$Path = "X:\Evergreen"
$vclist = Get-VcList | Save-VcRedist -Path "$Path\VcRedist"
Import-VcMdtApplication -VcList ($vclist) -Path "$Path\VcRedist" -MdtPath \fabricmdt\FactoryDeployment -Verbose -AppFolder VCRedist3

resolves the issue, but that parameter really needs to be renamed from -VcList to -SaveVcRedist or something so we know what data to supply it, especially since the useful error message is never called.

BronsonMagnan commented 10 months ago

What is the point of the 'path' parameter then if we are pulling the path from the output of save-vcredist?

BronsonMagnan commented 10 months ago

Alright I found this discussion: https://github.com/aaronparker/vcredist/discussions/123 I still think it is weird that a parameter called vcList doesn't take the object created by a cmdlet called get-vclist. Almost every other domain where powershell is used, this is the normal custom.

BronsonMagnan commented 10 months ago

The same problem with a different cmdlet here: https://github.com/aaronparker/vcredist/issues/153

BronsonMagnan commented 10 months ago

Please close issue, redefined the issue as https://github.com/aaronparker/vcredist/issues/155

aaronparker commented 8 months ago

This is currently working as designed, so the syntax would be:

Import

$VcList = Get-VcList | Save-VcRedist -Path E:\Temp\VcRedist
Update-VcMdtApplication -VcList $VcList -MdtPath \\localhost\Deployment\Automata

Update

$VcList = Get-VcList | Save-VcRedist -Path E:\Temp\VcRedist
Update-VcMdtApplication -VcList $VcList -MdtPath \\localhost\Deployment\Automata