Skip to content

Commit

Permalink
Merge pull request #640 from microsoft/main
Browse files Browse the repository at this point in the history
Release 07-23-21
  • Loading branch information
dpaulson45 authored Jul 23, 2021
2 parents 2bff367 + 17a85ea commit b7f6617
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 91 deletions.
30 changes: 8 additions & 22 deletions Diagnostics/HealthChecker/Analyzer/Invoke-AnalyzerEngine.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -579,32 +579,18 @@ Function Invoke-AnalyzerEngine {
$displayValue2013 = "Unknown"

if ($null -ne $osInformation.VcRedistributable) {
Write-VerboseOutput("VCRedist2012 Testing value: {0}" -f [HealthChecker.VCRedistVersion]::VCRedist2012.value__)
Write-VerboseOutput("VCRedist2013 Testing value: {0}" -f [HealthChecker.VCRedistVersion]::VCRedist2013.value__)

foreach ($detectedVisualRedistVersion in $osInformation.VcRedistributable) {
Write-VerboseOutput("Testing {0} version id '{1}'" -f $detectedVisualRedistVersion.DisplayName, $detectedVisualRedistVersion.VersionIdentifier)

if ($detectedVisualRedistVersion.DisplayName -like "Microsoft Visual C++ 2012*") {
$vcRedist2012Detected = $true
if ($detectedVisualRedistVersion.VersionIdentifier -eq [HealthChecker.VCRedistVersion]::VCRedist2012) {
$displayWriteType2012 = "Green"
$displayValue2012 = "{0} Version is current" -f $detectedVisualRedistVersion.DisplayVersion
}
} elseif ($detectedVisualRedistVersion.DisplayName -like "Microsoft Visual C++ 2013*") {
$vcRedist2013Detected = $true
if ($detectedVisualRedistVersion.VersionIdentifier -eq [HealthChecker.VCRedistVersion]::VCRedist2013) {
$displayWriteType2013 = "Green"
$displayValue2013 = "{0} Version is current" -f $detectedVisualRedistVersion.DisplayVersion
}
}
}

if (($vcRedist2012Detected -eq $true) -and ($displayWriteType2012 -ne "Green")) {
if (Test-VisualCRedistributableUpToDate -Year 2012 -Installed $osInformation.VcRedistributable) {
$displayWriteType2012 = "Green"
$displayValue2012 = "$((Get-VisualCRedistributableInfo 2012).VersionNumber) Version is current"
} elseif (Test-VisualCRedistributableInstalled -Year 2012 -Installed $osInformation.VcRedistributable) {
$displayValue2012 = "Redistributable is outdated"
}

if (($vcRedist2013Detected -eq $true) -and ($displayWriteType2013 -ne "Green")) {
if (Test-VisualCRedistributableUpToDate -Year 2013 -Installed $osInformation.VcRedistributable) {
$displayWriteType2013 = "Green"
$displayValue2013 = "$((Get-VisualCRedistributableInfo 2013).VersionNumber) Version is current"
} elseif (Test-VisualCRedistributableInstalled -Year 2013 -Installed $osInformation.VcRedistributable) {
$displayValue2013 = "Redistributable is outdated"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Function Get-OperatingSystemInformation {
-ScriptBlockDescription "Getting Current Time Zone" `
-CatchActionFunction ${Function:Invoke-CatchActions}
$osInformation.TLSSettings = Get-AllTlsSettingsFromRegistry -MachineName $Script:Server -CatchActionFunction ${Function:Invoke-CatchActions}
$osInformation.VcRedistributable = Get-VisualCRedistributableVersion -ComputerName $Script:Server -CatchActionFunction ${Function:Invoke-CatchActions}
$osInformation.VcRedistributable = Get-VisualCRedistributableInstalledVersion -ComputerName $Script:Server -CatchActionFunction ${Function:Invoke-CatchActions}
$osInformation.CredentialGuardEnabled = Get-CredentialGuardEnabled
$osInformation.RegistryValues.CurrentVersionUbr = Invoke-RegistryGetValue `
-MachineName $Script:Server `
Expand Down
2 changes: 1 addition & 1 deletion Diagnostics/HealthChecker/HealthChecker.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ if ($PSBoundParameters["Verbose"]) {
. .\DataCollection\ServerInformation\Get-OperatingSystemInformation.ps1
. .\DataCollection\ServerInformation\Get-PageFileInformation.ps1
. .\DataCollection\ServerInformation\Get-ServerRole.ps1
. $PSScriptRoot\..\..\Shared\Get-VisualCRedistributableVersion.ps1
. $PSScriptRoot\..\..\Shared\VisualCRedistributableVersionFunctions.ps1
. .\Analyzer\Add-AnalyzedResultInformation.ps1
. .\Analyzer\Get-DisplayResultsGroupingKey.ps1
. .\Analyzer\Invoke-AnalyzerEngine.ps1
Expand Down
9 changes: 0 additions & 9 deletions Diagnostics/HealthChecker/Helpers/Class.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,6 @@ try {
public string Seconds;
}
//enum for the dword values of the latest supported VC++ redistributable releases
//https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads
public enum VCRedistVersion
{
Unknown = 0,
VCRedist2012 = 184610406,
VCRedist2013 = 201367256
}
public class OSNetFrameworkInformation
{
public NetMajorVersion NetMajorVersion; //NetMajorVersion value
Expand Down
24 changes: 6 additions & 18 deletions Setup/SetupAssist/Checks/Test-PrerequisiteInstalled.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,22 @@
Function Test-PrerequisiteInstalled {
[CmdletBinding()]
param()
begin {
$2012VersionFound = $false
$2013VersionFound = $false
}

process {
$netVersion = Get-NETFrameworkVersion

if ($netVersion.MinimumValue -lt 528040) {
"Download .NET 4.8 and install: https://dotnet.microsoft.com/download/dotnet-framework/net48" | Receive-Output
}

$vcRedistributable = Get-VisualCRedistributableVersion

foreach ($detectedVc in $vcRedistributable) {

if ($detectedVc.VersionIdentifier -eq 201347597) {
$2013VersionFound = $true
} elseif ($detectedVc.VersionIdentifier -eq 184600103) {
$2012VersionFound = $true
}
}
$installed = Get-VisualCRedistributableInstalledVersion

if (-not $2012VersionFound) {
"Download Visual C++ 2012 Redistributable Package and install: https://www.microsoft.com/en-us/download/details.aspx?id=30679" | Receive-Output
if (-not (Test-VisualCRedistributableUpToDate -Year 2012 -Installed $installed)) {
"Download Visual C++ 2012 Redistributable Package and install: $((Get-VisualCRedistributableInfo 2012).DownloadUrl)" | Receive-Output
}

if (-not $2013VersionFound) {
"Download Visual C++ 2013 Redistributable Package and install: https://support.microsoft.com/en-us/topic/update-for-visual-c-2013-redistributable-package-d8ccd6a5-4e26-c290-517b-8da6cfdf4f10" | Receive-Output
if (-not (Test-VisualCRedistributableUpToDate -Year 2013 -Installed $installed)) {
"Download Visual C++ 2013 Redistributable Package and install: $((Get-VisualCRedistributableInfo 2013).DownloadUrl)" | Receive-Output
}
}
}
7 changes: 5 additions & 2 deletions Setup/SetupAssist/Checks/Test-ValidHomeMdb.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

Function Test-ValidHomeMDB {
$filePath = "$PSScriptRoot\validHomeMdb.txt"
ldifde -t 3268 -r "(&(objectClass=user)(mailnickname=*)(!(msExchRemoteRecipientType=*))(!(targetAddress=*))(msExchHideFromAddressLists=TRUE)(!(cn=HealthMailbox*)))" -l "distinguishedName,homeMDB" -f $filePath | Out-Null
$rootDSE = [ADSI]("LDAP://RootDSE")
ldifde -t 3268 -r "(&(objectClass=user)(mailnickname=*)(!(msExchRemoteRecipientType=*))(!(targetAddress=*))(msExchHideFromAddressLists=TRUE)(!(cn=HealthMailbox*)))" `
-l "distinguishedName,homeMDB" -f $filePath -d $rootDSE.rootDomainNamingContext | Out-Null

$ldifeObject = @(Get-Content $filePath | ConvertFrom-Ldif)

if ($ldifeObject.Count -gt 0) {
Expand Down Expand Up @@ -43,6 +46,6 @@ Function Test-ValidHomeMDB {
"All Critical Mailboxes have valid HomeMDB values" | Receive-Output
}
} else {
throw "Unexpected LDIF data."
Write-Error "Unexpected LDIF data in Test-ValidHomeMdb."
}
}
2 changes: 1 addition & 1 deletion Setup/SetupAssist/SetupAssist.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ param(
#REPO Shared
. $PSScriptRoot\..\..\Shared\Test-ScriptVersion.ps1
. $PSScriptRoot\..\..\Shared\Get-NETFrameworkVersion.ps1
. $PSScriptRoot\..\..\Shared\Get-VisualCRedistributableVersion.ps1
. $PSScriptRoot\..\..\Shared\VisualCRedistributableVersionFunctions.ps1

#REPO Shared Dependencies
. $PSScriptRoot\..\..\Shared\Get-RemoteRegistrySubKey.ps1
Expand Down
37 changes: 0 additions & 37 deletions Shared/Get-VisualCRedistributableVersion.ps1

This file was deleted.

101 changes: 101 additions & 0 deletions Shared/VisualCRedistributableVersionFunctions.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

. $PSScriptRoot\Invoke-ScriptBlockHandler.ps1

Function Get-VisualCRedistributableInstalledVersion {
[CmdletBinding()]
param(
[string]$ComputerName = $env:COMPUTERNAME,
[scriptblock]$CatchActionFunction
)
begin {
Write-Verbose "Calling: $($MyInvocation.MyCommand)"
$softwareList = New-Object 'System.Collections.Generic.List[object]'
}
process {
$installedSoftware = Invoke-ScriptBlockHandler -ComputerName $ComputerName `
-ScriptBlock { Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* } `
-ScriptBlockDescription "Querying for software" `
-CatchActionFunction $CatchActionFunction

foreach ($software in $installedSoftware) {

if ($software.DisplayName -like "Microsoft Visual C++ *") {
Write-Verbose "Microsoft Visual C++ Found: $($software.DisplayName)"
$softwareList.Add([PSCustomObject]@{
DisplayName = $software.DisplayName
DisplayVersion = $software.DisplayVersion
InstallDate = $software.InstallDate
VersionIdentifier = $software.Version
})
}
}
}
end {
Write-Verbose "Exiting: $($MyInvocation.MyCommand)"
return $softwareList
}
}

Function Get-VisualCRedistributableInfo {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[ValidateSet(2012, 2013)]
[int]
$Year
)

if ($Year -eq 2012) {
return [PSCustomObject]@{
VersionNumber = 184610406
DownloadUrl = "https://www.microsoft.com/en-us/download/details.aspx?id=30679"
DisplayName = "Microsoft Visual C++ 2012*"
}
} else {
return [PSCustomObject]@{
VersionNumber = 201367256
DownloadUrl = "https://support.microsoft.com/en-us/topic/update-for-visual-c-2013-redistributable-package-d8ccd6a5-4e26-c290-517b-8da6cfdf4f10"
DisplayName = "Microsoft Visual C++ 2013*"
}
}
}

Function Test-VisualCRedistributableInstalled {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, Position = 0)]
[ValidateSet(2012, 2013)]
[int]
$Year,

[Parameter(Mandatory = $true, Position = 1)]
[object]
$Installed
)

$desired = Get-VisualCRedistributableInfo $Year

return ($null -ne $Installed | Where-Object { $_.DisplayName -like $desired.DisplayName })
}

Function Test-VisualCRedistributableUpToDate {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, Position = 0)]
[ValidateSet(2012, 2013)]
[int]
$Year,

[Parameter(Mandatory = $true, Position = 1)]
[object]
$Installed
)

$desired = Get-VisualCRedistributableInfo $Year

return ($null -ne ($Installed | Where-Object {
$_.DisplayName -like $desired.DisplayName -and $_.VersionIdentifier -eq $desired.VersionNumber
}))
}

0 comments on commit b7f6617

Please sign in to comment.