I wanted to know if can check if a newer Version of a Package is installed in Powershell.
I wanted to install the Package "Microsoft.VCLibs.x86.14.00.appx" via powershell.
I do that by the command: Add-AppxPackage .\Microsoft.VCLibs.x86.14.00.appx
but then I get the error: HRESULT: 0x80073D06, The Package could not be installed because a higher version f this package is already installed.
I checked with Get-AppxPackage * Microsoft.vclibs.14* and yeah there is a higher Version. So is there a way to access the version and compare them? and than decide to install the Package or not?
like a script where I get the installed packages via "Get-AppxPackage * Microsoft.vclibs.14*" und foreach the result and access the version?
$FilePath = ".\Microsoft.VCLibs.x86.14.00.appx"
$FileVersion = (Get-ItemProperty -Path $FilePath).VersionInfo.ProductVersion
$HighestInstalledVersion = Get-AppxPackage -Name Microsoft.VCLibs* |
Sort-Object -Property Version |
Select-Object -ExpandProperty Version -Last 1
if ( $HighestInstalledVersion -lt $FileVersion ) {
Add-AppxPackage $FilePath
}
User contributions licensed under CC BY-SA 3.0