Skip to content
Merged
2 changes: 1 addition & 1 deletion .build/CodeFormatter.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ param(

. $PSScriptRoot\Load-Module.ps1

if (-not (Load-Module -Name PSScriptAnalyzer)) {
if (-not (Load-Module -Name PSScriptAnalyzer -MinimumVersion "1.20")) {
throw "PSScriptAnalyzer module could not be loaded"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,14 +361,14 @@ Function Invoke-RemoteMain {

if ($PassedInfo.MessageTrackingLogs -and
(-not ($Script:localServerObject.Version -eq 15 -and
$Script:localServerObject.CASOnly))) {
$Script:localServerObject.CASOnly))) {
$info = ($copyInfo -f ($Script:localServerObject.TransportInfo.HubLoggingInfo.MessageTrackingLogPath), ($Script:RootCopyToDirectory + "\Message_Tracking_Logs"))
$cmdsToRun += "Copy-LogsBasedOnTime {0}" -f $info
}

if ($PassedInfo.HubProtocolLogs -and
(-not ($Script:localServerObject.Version -eq 15 -and
$Script:localServerObject.CASOnly))) {
$Script:localServerObject.CASOnly))) {
$info = ($copyInfo -f ($Script:localServerObject.TransportInfo.HubLoggingInfo.ReceiveProtocolLogPath), ($Script:RootCopyToDirectory + "\Hub_Receive_Protocol_Logs"))
$cmdsToRun += "Copy-LogsBasedOnTime {0}" -f $info
$info = ($copyInfo -f ($Script:localServerObject.TransportInfo.HubLoggingInfo.SendProtocolLogPath), ($Script:RootCopyToDirectory + "\Hub_Send_Protocol_Logs"))
Expand All @@ -377,14 +377,14 @@ Function Invoke-RemoteMain {

if ($PassedInfo.HubConnectivityLogs -and
(-not ($Script:localServerObject.Version -eq 15 -and
$Script:localServerObject.CASOnly))) {
$Script:localServerObject.CASOnly))) {
$info = ($copyInfo -f ($Script:localServerObject.TransportInfo.HubLoggingInfo.ConnectivityLogPath), ($Script:RootCopyToDirectory + "\Hub_Connectivity_Logs"))
$cmdsToRun += "Copy-LogsBasedOnTime {0}" -f $info
}

if ($PassedInfo.QueueInformation -and
(-not ($Script:localServerObject.Version -eq 15 -and
$Script:localServerObject.CASOnly))) {
$Script:localServerObject.CASOnly))) {

if ($Script:localServerObject.Version -ge 15 -and
$null -ne $Script:localServerObject.TransportInfo.HubLoggingInfo.QueueLogPath) {
Expand Down Expand Up @@ -415,15 +415,15 @@ Function Invoke-RemoteMain {

if ($PassedInfo.FrontEndConnectivityLogs -and
(-not ($Script:localServerObject.Version -eq 15 -and
$Script:localServerObject.MailboxOnly))) {
$Script:localServerObject.MailboxOnly))) {
Write-ScriptDebug("Collecting FrontEndConnectivityLogs")
$info = ($copyInfo -f ($Script:localServerObject.TransportInfo.FELoggingInfo.ConnectivityLogPath), ($Script:RootCopyToDirectory + "\FE_Connectivity_Logs"))
$cmdsToRun += "Copy-LogsBasedOnTime {0}" -f $info
}

if ($PassedInfo.FrontEndProtocolLogs -and
(-not ($Script:localServerObject.Version -eq 15 -and
$Script:localServerObject.MailboxOnly))) {
$Script:localServerObject.MailboxOnly))) {
Write-ScriptDebug("Collecting FrontEndProtocolLogs")
$info = ($copyInfo -f ($Script:localServerObject.TransportInfo.FELoggingInfo.ReceiveProtocolLogPath), ($Script:RootCopyToDirectory + "\FE_Receive_Protocol_Logs"))
$cmdsToRun += "Copy-LogsBasedOnTime {0}" -f $info
Expand All @@ -433,7 +433,7 @@ Function Invoke-RemoteMain {

if ($PassedInfo.MailboxConnectivityLogs -and
(-not ($Script:localServerObject.Version -eq 15 -and
$Script:localServerObject.CASOnly))) {
$Script:localServerObject.CASOnly))) {
Write-ScriptDebug("Collecting MailboxConnectivityLogs")
$info = ($copyInfo -f ($Script:localServerObject.TransportInfo.MBXLoggingInfo.ConnectivityLogPath + "\Delivery"), ($Script:RootCopyToDirectory + "\MBX_Delivery_Connectivity_Logs"))
$cmdsToRun += "Copy-LogsBasedOnTime {0}" -f $info
Expand All @@ -443,7 +443,7 @@ Function Invoke-RemoteMain {

if ($PassedInfo.MailboxProtocolLogs -and
(-not ($Script:localServerObject.Version -eq 15 -and
$Script:localServerObject.CASOnly))) {
$Script:localServerObject.CASOnly))) {
Write-ScriptDebug("Collecting MailboxProtocolLogs")
$info = ($copyInfo -f ($Script:localServerObject.TransportInfo.MBXLoggingInfo.ReceiveProtocolLogPath), ($Script:RootCopyToDirectory + "\MBX_Receive_Protocol_Logs"))
$cmdsToRun += "Copy-LogsBasedOnTime {0}" -f $info
Expand All @@ -453,7 +453,7 @@ Function Invoke-RemoteMain {

if ($PassedInfo.MailboxDeliveryThrottlingLogs -and
(!($Script:localServerObject.Version -eq 15 -and
$Script:localServerObject.CASOnly))) {
$Script:localServerObject.CASOnly))) {
Write-ScriptDebug("Collecting Mailbox Delivery Throttling Logs")
$info = ($copyInfo -f ($Script:localServerObject.TransportInfo.MBXLoggingInfo.MailboxDeliveryThrottlingLogPath), ($Script:RootCopyToDirectory + "\MBX_Delivery_Throttling_Logs"))
$cmdsToRun += "Copy-LogsBasedOnTime {0}" -f $info
Expand Down Expand Up @@ -519,3 +519,4 @@ Function Invoke-RemoteMain {
Write-ScriptDebug ("No errors occurred within the script")
}
}

13 changes: 7 additions & 6 deletions Diagnostics/HealthChecker/Analyzer/Invoke-AnalyzerEngine.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,10 @@ Function Invoke-AnalyzerEngine {

if (($serverMaintenance.InactiveComponents).Count -eq 0 -and
($null -eq $serverMaintenance.GetClusterNode -or
$serverMaintenance.GetClusterNode.State -eq "Up") -and
$serverMaintenance.GetClusterNode.State -eq "Up") -and
($null -eq $serverMaintenance.GetMailboxServer -or
($serverMaintenance.GetMailboxServer.DatabaseCopyActivationDisabledAndMoveNow -eq $false -and
$serverMaintenance.GetMailboxServer.DatabaseCopyAutoActivationPolicy -eq "Unrestricted"))) {
$serverMaintenance.GetMailboxServer.DatabaseCopyAutoActivationPolicy -eq "Unrestricted"))) {
$analyzedResults = Add-AnalyzedResultInformation -Name "Exchange Server Maintenance" -Details "Server is not in Maintenance Mode" `
-DisplayGroupingKey $keyExchangeInformation `
-DisplayWriteType "Green" `
Expand Down Expand Up @@ -619,7 +619,7 @@ Function Invoke-AnalyzerEngine {

if (($exchangeInformation.BuildInformation.ServerRole -ne [HealthChecker.ExchangeServerRole]::Edge -and
($displayWriteType2012 -eq "Yellow" -or
$displayWriteType2013 -eq "Yellow")) -or
$displayWriteType2013 -eq "Yellow")) -or
$displayWriteType2012 -eq "Yellow") {

$analyzedResults = Add-AnalyzedResultInformation -Details "Note: For more information about the latest C++ Redistributeable please visit: https://aka.ms/HC-LatestVC`r`n`t`tThis is not a requirement to upgrade, only a notification to bring to your attention." `
Expand Down Expand Up @@ -1283,7 +1283,7 @@ Function Invoke-AnalyzerEngine {
$currentTlsVersion.ServerDisabledByDefault -or
$currentTlsVersion.ClientDisabledByDefault) -and
($currentNetVersion.SystemDefaultTlsVersions -eq $false -or
$currentNetVersion.WowSystemDefaultTlsVersions -eq $false)) {
$currentNetVersion.WowSystemDefaultTlsVersions -eq $false)) {
$analyzedResults = Add-AnalyzedResultInformation -Details ("Error: SystemDefaultTlsVersions is not set to the recommended value. Please visit on how to properly enable TLS 1.2 https://aka.ms/HC-TLSPart2") `
-DisplayGroupingKey $keySecuritySettings `
-DisplayCustomTabNumber 3 `
Expand Down Expand Up @@ -1622,7 +1622,7 @@ Function Invoke-AnalyzerEngine {
$null -ne $appRestarts.Schedule -or
($appRestarts.Time -ne "00:00:00" -and
($webAppKey -ne "MSExchangeOWAAppPool" -and
$webAppKey -ne "MSExchangeECPAppPool")))
$webAppKey -ne "MSExchangeECPAppPool")))

$outputObjectDisplayValue.Add(([PSCustomObject]@{
AppPoolName = $webAppKey
Expand Down Expand Up @@ -1724,7 +1724,7 @@ Function Invoke-AnalyzerEngine {

if (($fileBuildPart -lt $securityFixedBuildPart) -or
($fileBuildPart -eq $securityFixedBuildPart -and
$filePrivatePart -lt $securityFixedPrivatePart)) {
$filePrivatePart -lt $securityFixedPrivatePart)) {
foreach ($cveName in $CVENames) {
$details = "{0}`r`n`t`tSee: https://portal.msrc.microsoft.com/en-us/security-guidance/advisory/{0} for more information." -f $cveName
$Script:Vulnerabilities += $details
Expand Down Expand Up @@ -2287,3 +2287,4 @@ Function Invoke-AnalyzerEngine {
return $Script:AnalyzedInformation
}


Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Function Get-ExchangeInformation {
$buildInformation.ServerRole -le [HealthChecker.ExchangeServerRole]::Mailbox) -or
($buildInformation.MajorVersion -eq [HealthChecker.ExchangeMajorVersion]::Exchange2013 -and
($buildInformation.ServerRole -eq [HealthChecker.ExchangeServerRole]::ClientAccess -or
$buildInformation.ServerRole -eq [HealthChecker.ExchangeServerRole]::MultiRole))) {
$buildInformation.ServerRole -eq [HealthChecker.ExchangeServerRole]::MultiRole))) {
$exchangeInformation.GetOwaVirtualDirectory = Get-OwaVirtualDirectory -Identity ("{0}\owa (Default Web Site)" -f $Script:Server) -ADPropertiesOnly
$exchangeInformation.GetWebServicesVirtualDirectory = Get-WebServicesVirtualDirectory -Server $Script:Server
}
Expand Down Expand Up @@ -462,3 +462,4 @@ Function Get-ExchangeInformation {
Write-Verbose "Exiting: Get-ExchangeInformation"
return $exchangeInformation
}

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Function Get-TimeZoneInformationRegistrySettings {

if ($dynamicDaylightTimeDisabled -ne 0 -and
($standardStartNonZeroValue -or
$daylightStartNonZeroValue)) {
$daylightStartNonZeroValue)) {
Write-Verbose "Determined that there is a chance the settings set could cause a DST issue."
$dstIssueDetected = $true
$actionsToTake += "High Warning: DynamicDaylightTimeDisabled is set, Windows can not properly detect any DST rule changes in your time zone. `
Expand All @@ -50,3 +50,4 @@ Function Get-TimeZoneInformationRegistrySettings {
}
}
}

5 changes: 3 additions & 2 deletions Diagnostics/HealthChecker/HealthChecker.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ Function Main {

if (-not (Confirm-Administrator) -and
(-not $AnalyzeDataOnly -and
-not $BuildHtmlServersReport -and
-not $ScriptUpdateOnly)) {
-not $BuildHtmlServersReport -and
-not $ScriptUpdateOnly)) {
Write-Warning "The script needs to be executed in elevated mode. Start the Exchange Management Shell as an Administrator."
$Error.Clear()
Start-Sleep -Seconds 2;
Expand Down Expand Up @@ -331,3 +331,4 @@ try {
}
RevertProperForegroundColor
}

3 changes: 2 additions & 1 deletion PSScriptAnalyzerSettings.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

ExcludeRules = @(
'PSAvoidUsingWriteHost',
'PSReviewUnusedParameter'
'PSReviewUnusedParameter',
'PSUseSingularNouns'
)

Rules = @{
Expand Down
48 changes: 37 additions & 11 deletions PublicFolders/src/SourceSideValidations/SourceSideValidations.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ param (
. $PSScriptRoot\Get-FolderData.ps1
. $PSScriptRoot\JobQueue.ps1
. $PSScriptRoot\..\..\..\Shared\Test-ScriptVersion.ps1
. $PSScriptRoot\..\..\..\Shared\Out-Columns.ps1

if (-not $SkipVersionCheck) {
if (Test-ScriptVersion -AutoUpdate) {
Expand All @@ -52,14 +53,37 @@ if (-not $SkipVersionCheck) {
}
}

$errorColor = "Red"
$configuredErrorColor = (Get-Host).PrivateData.ErrorForegroundColor
if ($configuredErrorColor -is [ConsoleColor]) {
$errorColor = $configuredErrorColor
}

$warningColor = "Yellow"
$configuredWarningColor = (Get-Host).PrivateData.WarningForegroundColor
if ($configuredWarningColor -is [ConsoleColor]) {
$warningColor = $configuredWarningColor
}

$severityColorizer = {
param($o, $propName)
if ($propName -eq "Severity") {
switch ($o.$propName) {
"Error" { $errorColor }
"Warning" { $warningColor }
}
}
}

if ($SummarizePreviousResults) {
$results = Import-Csv $ResultsFile
$results | Write-TestDumpsterMappingResult
$results | Write-TestFolderLimitResult
$results | Write-TestFolderNameResult
$results | Write-TestMailEnabledFolderResult
$results | Write-TestPermissionResult
Write-Host
$summary = New-Object System.Collections.ArrayList
$summary.AddRange(@($results | Write-TestDumpsterMappingResult))
$summary.AddRange(@($results | Write-TestFolderLimitResult))
$summary.AddRange(@($results | Write-TestFolderNameResult))
$summary.AddRange(@($results | Write-TestMailEnabledFolderResult))
$summary.AddRange(@($results | Write-TestPermissionResult))
$summary | Out-Columns -LinesBetweenObjects 1 -ColorizerFunctions $severityColorizer
return
}

Expand Down Expand Up @@ -167,11 +191,13 @@ if ("Permissions" -in $Tests) {

# Output the results

$badDumpsters | Write-TestDumpsterMappingResult
$limitsExceeded | Write-TestFolderLimitResult
$badNames | Write-TestFolderNameResult
$badMailEnabled | Write-TestMailEnabledFolderResult
$badPermissions | Write-TestPermissionResult
$results = New-Object System.Collections.ArrayList
$results.AddRange(@($badDumpsters | Write-TestDumpsterMappingResult))
$results.AddRange(@($limitsExceeded | Write-TestFolderLimitResult))
$results.AddRange(@($badNames | Write-TestFolderNameResult))
$results.AddRange(@($badMailEnabled | Write-TestMailEnabledFolderResult))
$results.AddRange(@($badPermissions | Write-TestPermissionResult))
$results | Out-Columns -LinesBetweenObjects 1

Write-Host
Write-Host "Validation results were written to file:"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

. $PSScriptRoot\..\Get-ResultSummary.ps1

function Write-TestDumpsterMappingResult {
[CmdletBinding()]
param (
Expand All @@ -21,11 +23,8 @@ function Write-TestDumpsterMappingResult {

end {
if ($badDumpsters.Count -gt 0) {
Write-Host
Write-Host $badDumpsters.Count "folders have invalid dumpster mappings. These folders"
Write-Host "are shown in the results CSV with a result type of BadDumpsterMapping."
Write-Host "The -ExcludeDumpsters switch can be used to skip these folders during migration, or the"
Write-Host "folders can be deleted."
Get-ResultSummary -ResultType $badDumpsters[0].ResultType -Severity $badDumpsters[0].Severity -Count $badDumpsters.Count -Action `
"Use the -ExcludeDumpsters switch to skip these folders during migration, or delete the folders."
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

function Get-ResultSummary {
[CmdletBinding()]
param (
[string]
$ResultType = $(throw "ResultType is mandatory"),

[ValidateSet("Information", "Warning", "Error")]
[string]
$Severity = $(throw "Severity is mandatory"),

[int]
$Count = $(throw "Count is mandatory"),

[string]
$Action = $(throw "Action is mandatory")
)

process {
[PSCustomObject]@{
ResultType = $ResultType
Severity = $Severity
Count = $Count
Action = $Action
}
}
}
Loading