Skip to content

Commit

Permalink
Merge pull request #1840 from microsoft/dpaul-HcvDirsCollect
Browse files Browse the repository at this point in the history
Collect the virtual directory information in HC
  • Loading branch information
dpaulson45 authored Oct 4, 2023
2 parents f92f47a + 8481aff commit 0d4812e
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ function Invoke-AnalyzerExchangeInformation {
$keyExchangeInformation = Get-DisplayResultsGroupingKey -Name "Exchange Information" -DisplayOrder $Order
$exchangeInformation = $HealthServerObject.ExchangeInformation
$hardwareInformation = $HealthServerObject.HardwareInformation
$getWebServicesVirtualDirectory = $exchangeInformation.VirtualDirectories.GetWebServicesVirtualDirectory |
Where-Object { $_.Name -eq "EWS (Default Web Site)" }

$baseParams = @{
AnalyzedInformation = $AnalyzeResults
Expand Down Expand Up @@ -208,8 +210,8 @@ function Invoke-AnalyzerExchangeInformation {
if ($exchangeInformation.GetExchangeServer.IsEdgeServer -eq $false) {

Write-Verbose "Working on MRS Proxy Settings"
$mrsProxyDetails = $exchangeInformation.GetWebServicesVirtualDirectory.MRSProxyEnabled
if ($exchangeInformation.GetWebServicesVirtualDirectory.MRSProxyEnabled) {
$mrsProxyDetails = $getWebServicesVirtualDirectory.MRSProxyEnabled
if ($getWebServicesVirtualDirectory.MRSProxyEnabled) {
$mrsProxyDetails = "$mrsProxyDetails`n`r`t`tKeep MRS Proxy disabled if you do not plan to move mailboxes cross-forest or remote"
$mrsProxyWriteType = "Yellow"
} else {
Expand Down Expand Up @@ -294,10 +296,10 @@ function Invoke-AnalyzerExchangeInformation {
}
Add-AnalyzedResultInformation @params

if (-not ([string]::IsNullOrWhiteSpace($exchangeInformation.GetWebServicesVirtualDirectory.InternalNLBBypassUrl))) {
if (-not ([string]::IsNullOrWhiteSpace($getWebServicesVirtualDirectory.InternalNLBBypassUrl))) {
$params = $baseParams + @{
Name = "EWS Internal Bypass URL Set"
Details = "$($exchangeInformation.GetWebServicesVirtualDirectory.InternalNLBBypassUrl) - Can cause issues after KB 5001779"
Details = "$($getWebServicesVirtualDirectory.InternalNLBBypassUrl) - Can cause issues after KB 5001779"
DisplayWriteType = "Red"
}
Add-AnalyzedResultInformation @params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ function Invoke-AnalyzerSecurityCve-2021-1730 {
$SecurityObject.IsEdgeServer -eq $false) {

$downloadDomainsEnabled = $SecurityObject.OrgInformation.EnableDownloadDomains
$owaVDirObject = $SecurityObject.ExchangeInformation.GetOwaVirtualDirectory
$owaVDirObject = $SecurityObject.ExchangeInformation.VirtualDirectories.GetOwaVirtualDirectory |
Where-Object { $_.Name -eq "owa (Default Web Site)" }
$displayWriteType = "Green"

if (-not ($downloadDomainsEnabled)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
. $PSScriptRoot\Get-ExchangeServerCertificates.ps1
. $PSScriptRoot\Get-ExchangeServerMaintenanceState.ps1
. $PSScriptRoot\Get-ExchangeUpdates.ps1
. $PSScriptRoot\Get-ExchangeVirtualDirectories.ps1
. $PSScriptRoot\Get-ExSetupDetails.ps1
. $PSScriptRoot\Get-FIPFSScanEngineVersionState.ps1
. $PSScriptRoot\Get-ServerRole.ps1
Expand Down Expand Up @@ -55,13 +56,7 @@ function Get-ExchangeInformation {
Invoke-CatchActions
}

try {
$getOwaVirtualDirectory = Get-OwaVirtualDirectory -Identity ("{0}\owa (Default Web Site)" -f $Server) -ADPropertiesOnly -ErrorAction Stop
$getWebServicesVirtualDirectory = Get-WebServicesVirtualDirectory -Server $Server -ErrorAction Stop
} catch {
Write-Verbose "Failed to get OWA or EWS virtual directory"
Invoke-CatchActions
}
$getExchangeVirtualDirectories = Get-ExchangeVirtualDirectories -Server $Server

$registryValues = Get-ExchangeRegistryValues -MachineName $Server -CatchActionFunction ${Function:Invoke-CatchActions}
$serverExchangeBinDirectory = [System.Io.Path]::Combine($registryValues.MsiInstallPath, "Bin\")
Expand Down Expand Up @@ -161,9 +156,8 @@ function Get-ExchangeInformation {
return [PSCustomObject]@{
BuildInformation = $buildInformation
GetExchangeServer = $getExchangeServer
VirtualDirectories = $getExchangeVirtualDirectories
GetMailboxServer = $getMailboxServer
GetOwaVirtualDirectory = $getOwaVirtualDirectory
GetWebServicesVirtualDirectory = $getWebServicesVirtualDirectory
ExtendedProtectionConfig = $extendedProtectionConfig
ExchangeConnectors = $exchangeConnectors
ExchangeServicesNotRunning = [array]$exchangeServicesNotRunning
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

. $PSScriptRoot\..\..\..\..\Shared\ErrorMonitorFunctions.ps1

function Get-ExchangeVirtualDirectories {
param(
[Parameter(Mandatory = $true)]
[string]$Server
)
begin {
Write-Verbose "Calling: $($MyInvocation.MyCommand)"

$failedString = "Failed to get {0} virtual directory."
$getActiveSyncVirtualDirectory = $null
$getAutoDiscoverVirtualDirectory = $null
$getEcpVirtualDirectory = $null
$getMapiVirtualDirectory = $null
$getOabVirtualDirectory = $null
$getOutlookAnywhere = $null
$getOwaVirtualDirectory = $null
$getPowerShellVirtualDirectory = $null
$getWebServicesVirtualDirectory = $null
$paramsNoShow = @{
Server = $Server
ErrorAction = "Stop"
ADPropertiesOnly = $true
}
$params = $paramsNoShow + @{
ShowMailboxVirtualDirectories = $true
}
}
process {
try {
$getActiveSyncVirtualDirectory = Get-ActiveSyncVirtualDirectory @params
} catch {
Write-Verbose ($failedString -f "EAS")
Invoke-CatchActions
}

try {
$getAutoDiscoverVirtualDirectory = Get-AutodiscoverVirtualDirectory @params
} catch {
Write-Verbose ($failedString -f "Autodiscover")
Invoke-CatchActions
}

try {
$getEcpVirtualDirectory = Get-EcpVirtualDirectory @params
} catch {
Write-Verbose ($failedString -f "ECP")
Invoke-CatchActions
}

try {
# Doesn't have ShowMailboxVirtualDirectories
$getMapiVirtualDirectory = Get-MapiVirtualDirectory @paramsNoShow
} catch {
Write-Verbose ($failedString -f "Mapi")
Invoke-CatchActions
}

try {
$getOabVirtualDirectory = Get-OabVirtualDirectory @params
} catch {
Write-Verbose ($failedString -f "OAB")
Invoke-CatchActions
}

try {
$getOutlookAnywhere = Get-OutlookAnywhere @params
} catch {
Write-Verbose ($failedString -f "Outlook Anywhere")
Invoke-CatchActions
}

try {
$getOwaVirtualDirectory = Get-OwaVirtualDirectory @params
} catch {
Write-Verbose ($failedString -f "OWA")
Invoke-CatchActions
}

try {
$getPowerShellVirtualDirectory = Get-PowerShellVirtualDirectory @params
} catch {
Write-Verbose ($failedString -f "PowerShell")
Invoke-CatchActions
}

try {
$getWebServicesVirtualDirectory = Get-WebServicesVirtualDirectory @params
} catch {
Write-Verbose ($failedString -f "EWS")
Invoke-CatchActions
}
}
end {
return [PSCustomObject]@{
GetActiveSyncVirtualDirectory = $getActiveSyncVirtualDirectory
GetAutoDiscoverVirtualDirectory = $getAutoDiscoverVirtualDirectory
GetEcpVirtualDirectory = $getEcpVirtualDirectory
GetMapiVirtualDirectory = $getMapiVirtualDirectory
GetOabVirtualDirectory = $getOabVirtualDirectory
GetOutlookAnywhere = $getOutlookAnywhere
GetOwaVirtualDirectory = $getOwaVirtualDirectory
GetPowerShellVirtualDirectory = $getPowerShellVirtualDirectory
GetWebServicesVirtualDirectory = $getWebServicesVirtualDirectory
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ Describe "Testing Health Checker by Mock Data Imports" {
Mock Get-ReceiveConnector { return Import-Clixml "$Script:MockDataCollectionRoot\Exchange\GetReceiveConnector.xml" }
Mock Get-SendConnector { return Import-Clixml "$Script:MockDataCollectionRoot\Exchange\GetSendConnector.xml" }
Mock Get-DynamicDistributionGroup { return Import-Clixml "$Script:MockDataCollectionRoot\Exchange\GetDynamicDistributionGroupPfMailboxes.xml" }
Mock Get-ActiveSyncVirtualDirectory { return $null }
Mock Get-AutodiscoverVirtualDirectory { return $null }
Mock Get-EcpVirtualDirectory { return $null }
Mock Get-MapiVirtualDirectory { return $null }
Mock Get-OutlookAnywhere { return $null }
Mock Get-PowerShellVirtualDirectory { return $null }

$Error.Clear()
Get-OrganizationInformation -EdgeServer $false | Out-Null
Expand Down Expand Up @@ -92,6 +98,12 @@ Describe "Testing Health Checker by Mock Data Imports" {
Assert-MockCalled Get-ExchangeDiagnosticInfo -Exactly 1
Assert-MockCalled Get-ExchangeADSplitPermissionsEnabled -Exactly 1
Assert-MockCalled Get-DynamicDistributionGroup -Exactly 1
Assert-MockCalled Get-ActiveSyncVirtualDirectory -Exactly 1
Assert-MockCalled Get-AutodiscoverVirtualDirectory -Exactly 1
Assert-MockCalled Get-EcpVirtualDirectory -Exactly 1
Assert-MockCalled Get-MapiVirtualDirectory -Exactly 1
Assert-MockCalled Get-OutlookAnywhere -Exactly 1
Assert-MockCalled Get-PowerShellVirtualDirectory -Exactly 1
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,18 @@ function Get-OrganizationConfig {
function Get-DynamicDistributionGroup {
return Import-Clixml "$Script:MockDataCollectionRoot\Exchange\GetDynamicDistributionGroupPfMailboxes.xml"
}
# virtual directory cmdlets to return null till we do actual checks against the vDirs.
function Get-ActiveSyncVirtualDirectory { return $null }

function Get-AutodiscoverVirtualDirectory { return $null }

function Get-EcpVirtualDirectory { return $null }

function Get-MapiVirtualDirectory { return $null }

function Get-OutlookAnywhere { return $null }

function Get-PowerShellVirtualDirectory { return $null }

function Get-HybridConfiguration { return $null }

Expand Down

0 comments on commit 0d4812e

Please sign in to comment.