-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGet-InstalledVCRedistVersions.ps1
More file actions
64 lines (55 loc) · 1.67 KB
/
Get-InstalledVCRedistVersions.ps1
File metadata and controls
64 lines (55 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<#
.SYNOPSIS
Extract information about the versions of Microsoft Visual C++
Redistributable on this system from a given registry path.
.DESCRIPTION
Return a string[] with the names of the Microsoft Visual C++
Redistributables listed at the specified registry path.
.PARAMETER RegPath
[Required][String]
Registry path that presumably contains information about
installed VC++ redistributables.
.EXAMPLE
Get-InstalledVCRedistVersionsFromRegPath
-RegPath "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*"
#>
function Get-InstalledVCRedistVersionsFromRegPath
{
Param(
[Parameter(Mandatory=$True)]
[string]$RegPath
)
return Get-ItemProperty $RegPath | ? {
$_ -and $_.DisplayName -and
$_.DisplayName.StartsWith('Microsoft Visual C++') -and
$_.DisplayName.Contains('Redistributable')
} | % { $_.DisplayName }
}
<#
.SYNOPSIS
Identify all the different versions of Microsoft Visual C++
Redistributables installed on this system.
.DESCRIPTION
Return a string[] with the names of the various Microsoft Visual C++
Redistributables installed on this system.
.EXAMPLE
# Get the actual version numbers (years) of the Microsoft Visual C++
# Redistributables on this system.
[string[]]$InstalledVersions = Get-InstalledVCRedistVersions
$InstalledVersions | % {
$_.Split(' ')[3]
}
#>
function Get-InstalledVCRedistVersions
{
[string[]]$InstalledVersions = @()
[string[]]$RegPaths = @(
'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*',
'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
)
$RegPaths | % {
$InstalledVersions +=
Get-InstalledVCRedistVersionsFromRegPath -RegPath $_
}
return $InstalledVersions
}