AK546371

Monitor_AK546371 (UnitMonitor)

Exchange 2010 Client Access Server not present in Active Directory Site

Knowledge Base article:

External

http://go.microsoft.com/fwlink/?LinkId=228763

Element properties:

TargetMicrosoft.KnowledgeServices.Exchange.2010.MailboxRole
Parent MonitorSystem.Health.ConfigurationState
CategoryAlert
EnabledTrue
Alert GenerateTrue
Alert SeverityWarning
Alert PriorityNormal
Alert Auto ResolveTrue
Monitor TypeMicrosoft.KnowledgeServices.Library.PowerShellMonitorEx
RemotableTrue
AccessibilityPublic
Alert Message
Exchange 2010 Client Access Server not present in Active Directory Site
<Details>
<Content>Although there is a Mailbox server role installed in the Active Directory site, at least one Client Access server role with a matching Exchange version was not found in the site. For more information about deploying the Client Access server role in a site, see "Deploying Exchange 2010" in the Exchange Server 2010 product documentation.</Content>
<CollectedInformation>
<Info>
<Name>Active Directory Site</Name>
<Value>{0}</Value>
</Info>
</CollectedInformation>
</Details>
RunAsDefault
CommentSupportTopic=TBD;VersionNumber=1.0.1.0;

Source Code:

<UnitMonitor ID="Monitor_AK546371" Comment="SupportTopic=TBD;VersionNumber=1.0.1.0;" Accessibility="Public" Enabled="true" Target="MicrosoftKnowledgeServicesExchange2010Library!Microsoft.KnowledgeServices.Exchange.2010.MailboxRole" ParentMonitorID="Health!System.Health.ConfigurationState" Remotable="true" Priority="Normal" TypeID="KnowledgeServicesLibrary!Microsoft.KnowledgeServices.Library.PowerShellMonitorEx" ConfirmDelivery="true">
<Category>Alert</Category>
<AlertSettings AlertMessage="MonitorMessagebda771871b014a448f19056214661ca0">
<AlertOnState>Error</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>Warning</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Data/Context/Property[@Name='ActiveDirectorySite']$</AlertParameter1>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="Success" MonitorTypeStateID="Success" HealthState="Success"/>
<OperationalState ID="Error" MonitorTypeStateID="Error" HealthState="Error"/>
</OperationalStates>
<Configuration>
<ScriptName>AK546371.ps1</ScriptName>
<Parameters>
<Parameter>
<Name>ServerName</Name>
<Value>$Target/Property[Type="MicrosoftKnowledgeServicesExchange2010Library!Microsoft.KnowledgeServices.Exchange.2010.MailboxRole"]/Name$</Value>
</Parameter>
</Parameters>
<ScriptBody><Script>


param($ServerName)

$ErrorActionPreference = "Stop"

# Set up the arguments
$scriptargs = new-object psobject
$scriptargs | add-member NoteProperty "ServerName" $ServerName

# Set up the output
$global:scriptoutput = new-object psobject
$scriptoutput | add-member NoteProperty "HasIssue" $false
$scriptoutput | add-member NoteProperty "ActiveDirectorySite" ""
#-----------------------------------------------------
# MAIN CODE SECTION
#-----------------------------------------------------

# Environment

$scriptenv = new-object psobject
$scriptenv | add-member NoteProperty "ThisExchangeServer" $null
$scriptenv | add-member NoteProperty "ExchangeServersInThisSite" @()
$scriptenv | add-member NoteProperty "IsSameVersion" $null
$scriptenv | add-member NoteProperty "IsClientAccessServer" $null
$scriptenv | add-member NoteProperty "IsClientAccessServerInThisSite" $null
$scriptenv | add-member NoteProperty "SiteRdn" ""



# Helper functions

#function to check whether there is a Client Access Server exists in the sites
Function Check-IsClientAccessServerInThisSite{
Param ([string]$ServerName = $scriptargs.ServerName)

# Get this Exchange Server
$scriptenv.ThisExchangeServer = Get-ExchangeServer -Identity $ServerName -ErrorAction SilentlyContinue

# Get all Exchange Servers in the same AD Site
$scriptenv.ExchangeServersInThisSite = Get-ExchangeServer | Where-Object {$_.Site.DistinguishedName -eq $scriptenv.ThisExchangeServer.Site.DistinguishedName}

# Verify whether this Exchagne Server has Mailbox Role intalled
If ($scriptenv.ThisExchangeServer.IsMailboxServer -eq $true){
$scriptenv.IsClientAccessServerInThisSite = $false

# Evaluate every Exchange Server in the same AD site
$scriptenv.SiteRdn = $scriptenv.ThisExchangeServer.Site.DistinguishedName
ForEach($ExchangeServer in $scriptenv.ExchangeServersInThisSite){
$scriptenv.IsSameVersion = $false
$scriptenv.IsClientAccessServer = $false
# Verify whether version of Exchange server is same as this Exchange server
If($ExchangeServer.AdminDisplayVersion.Major -eq $scriptenv.ThisExchangeServer.AdminDisplayVersion.Major){
$scriptenv.IsSameVersion = $true
}

# Check whether version of Exchange has CAS role installed
If($ExchangeServer.IsClientAccessServer -eq $true){
$scriptenv.IsClientAccessServer = $true
}

# Verify whether any Exchange server is same version as this Exchange server and has CAS role
If(($scriptenv.IsClientAccessServer -eq $true) -and ($scriptenv.IsSameVersion -eq $true)){
$scriptenv.IsClientAccessServerInThisSite = $true
break
}
else{
$scriptenv.IsClientAccessServerInThisSite = $false
}
}
}
}


# Main function

Function AdvisorRule($scriptargs, $scriptoutput)
{
# All parameters should be populated outside of the main function.
# The mian function should only include the detection logic so that it can be easyly reused by the Atlanta authoring tool.

# Initialize parameters
$scriptenv.IsClientAccessServerInThisSite = $true
$scriptoutput.HasIssue = $false


# Set parameter values
Check-IsClientAccessServerInThisSite $scriptargs.ServerName
$scriptoutput.ActiveDirectorySite = $scriptenv.SiteRdn

# Detection Logic
If ($scriptenv.IsClientAccessServerInThisSite -eq $false){
#Raise alert
$scriptoutput.HasIssue = $true
}
}
AdvisorRule $scriptargs $scriptoutput

# set the output
$mom = new-object -comobject "MOM.ScriptAPI"
$bag = $mom.CreatePropertyBag()

if ($scriptoutput.HasIssue -ne $null)
{
$bag.AddValue("HasIssue", $scriptoutput.HasIssue)
}

if ($scriptoutput.ActiveDirectorySite -ne $null)
{
$bag.AddValue("ActiveDirectorySite", $scriptoutput.ActiveDirectorySite)
}

$bag

</Script></ScriptBody>
<SnapIns>
<SnapIn>Microsoft.Exchange.Management.PowerShell.E2010</SnapIn>
</SnapIns>
<TimeoutSeconds>300</TimeoutSeconds>
<Schedule>86372</Schedule>
<ErrorExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Boolean">Property[@Name='HasIssue']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="Boolean">true</Value>
</ValueExpression>
</SimpleExpression>
</ErrorExpression>
<SuccessExpression>
<Not>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Boolean">Property[@Name='HasIssue']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="Boolean">true</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</Not>
</SuccessExpression>
</Configuration>
</UnitMonitor>