Tri-existence detected in this Lync environment
http://go.microsoft.com/fwlink/?LinkId=322081
Target | Microsoft.KnowledgeServices.Lync.2010.CentralMgmtInfo | ||
Parent Monitor | System.Health.ConfigurationState | ||
Category | Alert | ||
Enabled | True | ||
Alert Generate | True | ||
Alert Severity | Warning | ||
Alert Priority | High | ||
Alert Auto Resolve | True | ||
Monitor Type | Microsoft.KnowledgeServices.Library.PowerShellMonitorEx | ||
Remotable | True | ||
Accessibility | Public | ||
Alert Message |
| ||
RunAs | Default | ||
Comment | SupportTopic=TBD;VersionNumber=1.0.0.0; |
<UnitMonitor ID="Monitor_AKN574242" Comment="SupportTopic=TBD;VersionNumber=1.0.0.0;" Accessibility="Public" Enabled="true" Target="MicrosoftKnowledgeServicesLyncLibrary!Microsoft.KnowledgeServices.Lync.2010.CentralMgmtInfo" ParentMonitorID="Health!System.Health.ConfigurationState" Remotable="true" Priority="High" TypeID="KnowledgeServicesLibrary!Microsoft.KnowledgeServices.Library.PowerShellMonitorEx" ConfirmDelivery="true">
<Category>Alert</Category>
<AlertSettings AlertMessage="MonitorMessage3d4573afe0b0421eb9add33bfb6f6fc5">
<AlertOnState>Error</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>High</AlertPriority>
<AlertSeverity>Warning</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Data/Context/Property[@Name='OfficeCommunicationPools']$</AlertParameter1>
<AlertParameter2>$Data/Context/Property[@Name='Lync2010Pools']$</AlertParameter2>
<AlertParameter3>$Data/Context/Property[@Name='Lync2013Pools']$</AlertParameter3>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="Success" MonitorTypeStateID="Success" HealthState="Success"/>
<OperationalState ID="Error" MonitorTypeStateID="Error" HealthState="Error"/>
</OperationalStates>
<Configuration>
<ScriptName>AKN574242.ps1</ScriptName>
<Parameters/>
<ScriptBody>
[ScriptBlock]$mainScriptBlock = {
$ErrorActionPreference = "Stop"
# Set up the arguments
$scriptargs = new-object psobject
# Set up the output
$global:scriptoutput = new-object psobject
$scriptoutput | add-member NoteProperty "HasIssue" $false
$scriptoutput | add-member NoteProperty "OfficeCommunicationPools" ""
$scriptoutput | add-member NoteProperty "Lync2010Pools" ""
$scriptoutput | add-member NoteProperty "Lync2013Pools" ""
#-----------------------------------------------------
# Environment
#-----------------------------------------------------
$script:lyncPath = ""
if (Join-Path $Env:CommonProgramFiles "\Microsoft Lync Server 2013\Modules\Lync\Lync.psd1" | Test-Path)
{
$script:lyncPath = Join-Path $Env:CommonProgramFiles "\Microsoft Lync Server 2013\Modules\Lync\Lync.psd1"
$script:lyncPSVer = 2013
}
elseif (Join-Path $Env:CommonProgramFiles "\Microsoft Lync Server 2010\Modules\Lync\Lync.psd1" | Test-Path)
{
$script:lyncPath = Join-Path $Env:CommonProgramFiles "\Microsoft Lync Server 2010\Modules\Lync\Lync.psd1"
$script:lyncPSVer = 2010
}
$ScriptEnv = New-Object psobject
$ScriptEnv | Add-Member NoteProperty "RuntimeError" $false
$ScriptEnv | Add-Member NoteProperty "HasIssue" $false
$ScriptEnv | add-member ScriptMethod "ImportLyncPSModule" -value {
$m = Get-Module -Name Lync
if ($m -eq $null)
{
Import-Module $script:lyncPath -ErrorAction:SilentlyContinue
}
}
$ScriptEnv | Add-Member ScriptMethod "IsCMSMaster" -Value {
Try
{
$cmsStatus = Get-CsManagementStoreReplicationStatus -CentralManagementStoreStatus
$agentHostFqdn = [System.Net.Dns]::GetHostByName([System.Net.Dns]::GetHostName()).HostName
return $cmsStatus.ActiveMasterFqdn -ieq $agentHostFqdn
}
Catch [Microsoft.Rtc.Management.ADConnect.CannotGetDomainInfoException]
{
}
Catch [Microsoft.Rtc.Common.Data.SqlConnectionException]
{
}
Catch [System.Data.SqlClient.SqlException]
{
}
return $false
}
#-----------------------------------------------------
# MAIN CODE SECTION
#-----------------------------------------------------
$scriptenv | Add-Member NoteProperty "OfficeCommunicationPools" ""
$scriptenv | Add-Member NoteProperty "Lync2010Pools" ""
$scriptenv | Add-Member NoteProperty "Lync2013Pools" ""
Function TestOCS2007()
{
$result = $false
$vers = @()
$fes = @(Get-CsService -Registrar) | Group-Object Version | Sort-Object Name
foreach($fe in $fes)
{
$vers += $fe.Name
foreach($group in $fe.Group)
{
switch($fe.Name)
{
4
{
$scriptenv.OfficeCommunicationPools += [string]::Format("<row><PoolFqdn>{0}</PoolFqdn></row>",$group.PoolFqdn)
}
5
{
$scriptenv.Lync2010Pools += [string]::Format("<row><PoolFqdn>{0}</PoolFqdn></row>",$group.PoolFqdn)
}
6
{
$scriptenv.Lync2013Pools += [string]::Format("<row><PoolFqdn>{0}</PoolFqdn></row>",$group.PoolFqdn)
}
default{}
}
}
}
if($vers -contains 4 -and $vers -contains 5 -and $vers -contains 6)
{
$result = $true
}
return $result
}
# Main Function
function AdvisorRule($scriptargs, $scriptoutput)
{
trap [Exception]
{
$scriptenv.RuntimeError = $true
continue
}
$scriptoutput.HasIssue = $false
if ($script:lyncPSVer -eq 2013)
{
$scriptenv.ImportLyncPSModule()
$scriptenv.HasIssue = (TestOCS2007)
if($scriptenv.HasIssue -eq $true -and $scriptenv.RuntimeError -eq $false)
{
$scriptoutput.HasIssue = $true
$scriptoutput.OfficeCommunicationPools = $scriptenv.OfficeCommunicationPools
$scriptoutput.Lync2010Pools = $scriptenv.Lync2010Pools
$scriptoutput.Lync2013Pools = $scriptenv.Lync2013Pools
}
}
}
AdvisorRule $scriptargs $scriptoutput
}
Function Test-NeedPSRemoting
{
$script:lyncPSVer = 0
if (Join-Path $Env:CommonProgramFiles "\Microsoft Lync Server 2013\Modules\Lync\Lync.psd1" | Test-Path)
{
$script:lyncPSVer = 2013
}
elseif (Join-Path $Env:CommonProgramFiles "\Microsoft Lync Server 2010\Modules\Lync\Lync.psd1" | Test-Path)
{
$script:lyncPSVer = 2010
}
$PSCLRVersion = [System.String]::Format("{0}.{1}", $PSVersionTable.CLRVersion.Major, $PSVersionTable.CLRVersion.Minor)
if (($PSCLRVersion -ieq "2.0") -and ($script:lyncPSVer -ieq 2013))
{
return $true
}
return $false
}
if ((Test-NeedPSRemoting))
{
[bool]$script:psRemotingEnabled = $false
# Enable PowerShell Remoting need elevated BUILTIN\Administrators privilege
$winRMService = (Get-Service WinRM -ErrorAction SilentlyContinue)
if ($winRMService -ne $null)
{
if ($winRMService.Status -ieq [System.ServiceProcess.ServiceControllerStatus]::Stopped)
{
$winRMService.Start()
$winRMService.WaitForStatus([System.ServiceProcess.ServiceControllerStatus]::Running, [System.TimeSpan]::FromSeconds(15))
}
$psSessionConfiguration = (Get-PSSessionConfiguration -Name "Microsoft.PowerShell" -ErrorAction SilentlyContinue)
if ($psSessionConfiguration.Permission.Contains("BUILTIN\Administrators AccessAllowed"))
{
$script:psRemotingEnabled = $true
}
}
# Call remote PS session when PSRemoting is enabled.
if ($script:psRemotingEnabled -eq $true)
{
$session = New-PSSession
Invoke-Command -Session $session -ScriptBlock $mainScriptBlock
$global:scriptoutput = Invoke-Command -Session $session -ScriptBlock {$global:scriptoutput}
Remove-PSSession -Session $session
}
}
else
{
& $mainScriptBlock
}
# set the output
$mom = new-object -comobject "MOM.ScriptAPI"
$bag = $mom.CreatePropertyBag()
if ($scriptoutput.HasIssue -ne $null)
{
$bag.AddValue("HasIssue", $scriptoutput.HasIssue)
}
if ($scriptoutput.OfficeCommunicationPools -ne $null)
{
$bag.AddValue("OfficeCommunicationPools", $scriptoutput.OfficeCommunicationPools)
}
if ($scriptoutput.Lync2010Pools -ne $null)
{
$bag.AddValue("Lync2010Pools", $scriptoutput.Lync2010Pools)
}
if ($scriptoutput.Lync2013Pools -ne $null)
{
$bag.AddValue("Lync2013Pools", $scriptoutput.Lync2013Pools)
}
$bag
</ScriptBody>
<SnapIns/>
<TimeoutSeconds>300</TimeoutSeconds>
<Schedule>15400</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>