Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
BronsonMagnan opened this issue Jan 11, 2024 · 9 comments

Comments

@BronsonMagnan
Copy link

$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

  • ... throw [System.Management.Automation.ValidationMetadataExc ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : MetadataError: (:) [], ParentContainsErrorRecordException
    • FullyQualifiedErrorId : RuntimeException

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

  • ... throw [System.Management.Automation.ValidationMetadataExc ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : MetadataError: (:) [], ParentContainsErrorRecordException
    • FullyQualifiedErrorId : RuntimeException
@BronsonMagnan
Copy link
Author

BronsonMagnan commented Jan 11, 2024

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
Copy link
Author

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
Copy link
Author

BronsonMagnan commented Jan 11, 2024

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
Copy link
Author

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
Copy link
Author

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

@BronsonMagnan
Copy link
Author

Alright I found this discussion: #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
Copy link
Author

The same problem with a different cmdlet here: #153

@BronsonMagnan
Copy link
Author

Please close issue, redefined the issue as #155

@aaronparker
Copy link
Owner

aaronparker commented Mar 11, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants