vcredist icon indicating copy to clipboard operation
vcredist copied to clipboard

Install-VcRedist expects 'Path' property not provided by Get-VcList

Open ei-zascha opened this issue 1 year ago • 3 comments

Expected Behavior

Any of the following should install the current VcRedists:   Get-VcList | Install-VcRedist

  {$VcList = Get-VcList    Install-VcRedist -VcList $VcList -Silent}

  {Get-VcList | Save-VcRedist -Path C:\Dev\Installs\VcRedist    $VcList = Get-VcList    Install-VcRedist -Path C:\Dev\Installs\VcRedist -VcList $VcList -Silent}

Current Behavior

Install fails and Install-VcRedist presents an error.

Failure Information (for bugs)

Get-VcList | Install-VcRedist -Verbose

VERBOSE: Matching installed VcRedists with: '(Microsoft Visual C.*)(\bRedistributable).*'.
VERBOSE: Add Architecture property to output object.
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

$VcList = Get-VcList Install-VcRedist -VcList $VcList -Verbose

VERBOSE: Matching installed VcRedists with: '(Microsoft Visual C.*)(\bRedistributable).*'.
VERBOSE: Add Architecture property to output object.
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

Get-VcList | Save-VcRedist -Path C:\Dev\Installs\VcRedist $VcList = Get-VcList Install-VcRedist -Path C:\Dev\Installs\VcRedist -VcList $VcList -Verbose

WARNING: Parameter 'Path' is obsolete. This parameter is not longer supported. The Path property must be on the object passed to -VcList.
VERBOSE: Matching installed VcRedists with: '(Microsoft Visual C.*)(\bRedistributable).*'.
VERBOSE: Add Architecture property to output object.
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

Steps to Reproduce

  1. See commands and output above

Context

  • VcRedist Version: Get-Module -ListAvailable VcRedist
    Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType  Version  Name      ExportedCommands
----------  -------  ----      ----------------
Script      4.1.494  VcRedist  {Export-VcManifest, Get-InstalledVcRedist, Get-VcList, Import-VcConfigMgrAppl...
Script      4.1.493  VcRedist  {Export-VcManifest, Get-InstalledVcRedist, Get-VcList, Import-VcConfigMgrAppl...
Script      4.1.484  VcRedist  {Export-VcManifest, Get-InstalledVcRedist, Get-VcList, Import-VcConfigMgrAppl...
Script      4.1.483  VcRedist  {Export-VcManifest, Get-InstalledVcRedist, Get-VcList, Import-VcConfigMgrAppl...
Script      4.1.480  VcRedist  {Export-VcManifest, Get-InstalledVcRedist, Get-VcList, Import-VcConfigMgrAppl...
Script      4.0.461  VcRedist  {Export-VcManifest, Get-InstalledVcRedist, Get-VcList, Import-VcConfigMgrAppl...
Script      4.0.460  VcRedist  {Export-VcManifest, Get-InstalledVcRedist, Get-VcList, Import-VcConfigMgrAppl...
Script      3.0.338  VcRedist  {Export-VcManifest, Get-InstalledVcRedist, Get-VcList, Import-VcConfigMgrAppl...
Script      3.0.337  VcRedist  {Export-VcManifest, Get-InstalledVcRedist, Get-VcList, Import-VcConfigMgrAppl...
  • Loaded Modules: Get-Module
ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   1.0.1.0    ActiveDirectory                     {Add-ADCentralAccessPolicyMember, Add-ADComputerServiceAccount, Add-ADDomainC...
Manifest   1.0.0.0    DnsClient                           {Resolve-DnsName, Add-DnsClientDohServerAddress, Add-DnsClientNrptRule, Clear...
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}
Manifest   3.0.0.0    Microsoft.PowerShell.Security       {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Get-AuthenticodeS...
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Manifest   3.0.0.0    Microsoft.WSMan.Management          {Connect-WSMan, Disable-WSManCredSSP, Disconnect-WSMan, Enable-WSManCredSSP...}
Manifest   1.0.0.0    NetTCPIP                            {Find-NetRoute, Get-NetCompartment, Get-NetIPAddress, Get-NetIPConfiguration...}
Script     0.0        oh-my-posh-core                     {Enable-PoshLineError, Enable-PoshTooltips, Enable-PoshTransientPrompt, Expor...
Script     1.4.8.1    PackageManagement                   {Find-Package, Find-PackageProvider, Get-Package, Get-PackageProvider...}
Script     1.1.0      posh-git                            {Add-PoshGitToProfile, Expand-GitCommand, Format-GitBranchName, Get-GitBranch...
Script     2.2.5      PowerShellGet                       {Find-Command, Find-DscResource, Find-Module, Find-RoleCapability...}
Script     2.3.4      PSReadLine                          {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PSReadLineKeyHandler,...
Binary     2.2.1.3    PSWindowsUpdate                     {Add-WUServiceManager, Enable-WURemoting, Get-WindowsUpdate, Get-WUApiVersion...
Script     0.11.0     Terminal-Icons                      {Add-TerminalIconsColorTheme, Add-TerminalIconsIconTheme, Format-TerminalIcon...
Script     4.1.494    VcRedist                            {Export-VcManifest, Get-InstalledVcRedist, Get-VcList, Import-VcConfigMgrAppl...
  • PowerShell Version: $PSVersionTable
Name                       Value
----                       -----
PSVersion                  5.1.22621.2506
PSEdition                  Desktop
PSCompatibleVersions       {1.0, 2.0, 3.0, 4.0...}
BuildVersion               10.0.22621.2506
CLRVersion                 4.0.30319.42000
WSManStackVersion          3.0
PSRemotingProtocolVersion  2.3
SerializationVersion       1.1.0.1
  • Operating System:
Caption                 : Microsoft Windows 11 Enterprise
Version                 : 10.0.22621
ServicePackMajorVersion : 0
OSArchitecture          : 64-bit
WindowsDirectory        : C:\WINDOWS

ei-zascha avatar Dec 19 '23 16:12 ei-zascha

Adding a Note Property (Because Add-Member can't add types to String input objects, you can specify the PassThru parameter to generate an output object) resolves the issue

Get-VcList | Save-VcRedist -Path C:\Dev\Installs\VcRedist
$VcList = Get-VcList
$VcList | Add-Member -NotePropertyMembers @{Path="C:\Dev\Installs\VcRedist"} -PassThru
$vclist | gm

   TypeName: System.Management.Automation.PSCustomObject

Name            MemberType   Definition
----            ----------   ----------
Equals          Method       bool Equals(System.Object obj)
GetHashCode     Method       int GetHashCode()
GetType         Method       type GetType()
ToString        Method       string ToString()
Architecture    NoteProperty string Architecture=x64
Install         NoteProperty string Install=/install /passive /norestart
Name            NoteProperty string Name=Visual C++ Redistributable for Visual Studio 2012 Update 4
Path            NoteProperty string Path=C:\Dev\Installs\VcRedist
ProductCode     NoteProperty string ProductCode={ca67548a-5ebe-413a-b50c-4b9ceb6d66c6}
Release         NoteProperty string Release=2012
SilentInstall   NoteProperty string SilentInstall=/quiet /norestart
SilentUninstall NoteProperty string SilentUninstall="%ProgramData%\Package Cache\{ca67548a-5ebe-413a-b50c-4b9ceb6d66c6}\vcredist_x64.ex... 
UninstallKey    NoteProperty string UninstallKey=32
URI             NoteProperty string URI=https://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredi... 
URL             NoteProperty string URL=https://www.microsoft.com/en-us/download/details.aspx?id=30679
Version         NoteProperty string Version=11.0.61030.0

ei-zascha avatar Dec 19 '23 17:12 ei-zascha

PowerShell Core v7.4.0 exhibits the same behavior:

Install-VcRedist -Path C:\Dev\Installs\VcRedist -VcList $VcList -Verbose

WARNING: Parameter 'Path' is obsolete. This parameter is not longer supported. The Path property must be on the object passed to -VcList.
VERBOSE: Matching installed VcRedists with: '(Microsoft Visual C.*)(\bRedistributable).*'.
VERBOSE: Add Architecture property to output object.
MetadataError: C:\Program Files\WindowsPowerShell\Modules\VcRedist\4.1.494\Private\Test-VcListObject.ps1:48
Line |
  48 |  …             throw [System.Management.Automation.ValidationMetadataExc …
     |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Property: 'Path' missing.

PS version info:

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.4.0
PSEdition                      Core
GitCommitId                    7.4.0
OS                             Microsoft Windows 10.0.22621
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Able to work around with the same method as above:

Get-VcList | Save-VcRedist -Path C:\Dev\Installs\VcRedist
$VcList = Get-VcList
$VcList | Add-Member -NotePropertyMembers @{Path="C:\Dev\Installs\VcRedist"} -PassThru

ei-zascha avatar Dec 19 '23 17:12 ei-zascha

Use this syntax:

Get-VcList | Save-VcList -Path C:\Temp\VcRedist | Install-VcRedist

or

Get-VcList -Release 2022 -Architecture x64 | Save-VcList -Path C:\Temp\VcRedist | Install-VcRedist

aaronparker avatar Mar 16 '24 23:03 aaronparker