@@ -40,7 +40,64 @@ function AddToStatInfo_SmEnv_SM() {
4040 # endregion
4141
4242 # region Connectors
43+ $Connectors = CreateElementForStatInfo - elemTagName Connectors
44+ $Connectors.SetAttribute (" Count_Total" , 0 )
45+ $Connectors.SetAttribute (" Count_Enabled" , 0 )
46+ $smEnv_SM.AppendChild ($Connectors )
4347
48+ $ConnectorsData = ConvertFrom-Csv (GetSanitizedCsv ( GetFileContentInSourceFolder SQL_Connectors.csv) )
49+ $Connectors.SetAttribute (" Count_Total" , $ConnectorsData.Count )
50+ $Connectors.SetAttribute (" Count_Enabled" , ($ConnectorsData | ? {$_.Enabled -eq $true }).Count)
51+ # endregion
52+
53+ # region Exchange Connectors
54+ $ExchangeConnectors = CreateElementForStatInfo - elemTagName Exchange
55+ $ExchangeConnectors.SetAttribute (" Version" , " None" )
56+ $ExchangeConnectors.SetAttribute (" Count_Total" , 0 )
57+ $ExchangeConnectors.SetAttribute (" Count_Enabled" , 0 )
58+ $ExchangeConnectors.SetAttribute (" Count_Enabled_ExchOnline" , 0 )
59+ $ExchangeConnectors.SetAttribute (" Count_Enabled_ExchOnPremise" , 0 )
60+ $Connectors.AppendChild ($ExchangeConnectors )
61+
62+ # check EC dll Version, only continue if there.
63+ $ExchangeConnectorDllInfo = ConvertFrom-Csv (GetFileContentInSourceFolder SCSM_Files.csv) | ? { $_.FullName.EndsWith (' \Microsoft.SystemCenter.ExchangeConnector.dll' ) }
64+ if ($ExchangeConnectorDllInfo ) {
65+ $ExchangeConnectors.SetAttribute (" Version" , $ExchangeConnectorDllInfo.Version )
66+
67+ $lfxMPstring = GetFileContentInSourceFolder - fileName " ServiceManager.LinkingFramework.Configuration___50daaf82-06ce-cacb-8cf5-3950aebae0b0.xml" - subFolderName MPXml
68+ $lfxMPxml = New-Object xml
69+ $lfxMPxml.LoadXml ($lfxMPstring )
70+
71+ $ExchangeConnectorsData = $lfxMPxml.SelectNodes (" /ManagementPack/Monitoring/Rules/Rule[WriteActions/WriteAction/Subscription/WindowsWorkflowConfiguration/WorkflowTypeName='Microsoft.SystemCenter.ExchangeConnector.ProcessEmailsWorkflow']" )
72+ $ExchangeConnectors.SetAttribute (" Count_Total" , $ExchangeConnectorsData.Count )
73+ $ExchangeConnectorsEnabledCount = ($ExchangeConnectorsData | ? {$_.Enabled -eq $true } | Measure).Count
74+ $ExchangeConnectors.SetAttribute (" Count_Enabled" , $ExchangeConnectorsEnabledCount )
75+
76+ $PotentialExchangeOnlineConnectorsData = $lfxMPxml.SelectNodes (" /ManagementPack/Monitoring/Rules/Rule[
77+ @Enabled='true' and
78+ WriteActions/WriteAction/Subscription/WindowsWorkflowConfiguration/WorkflowTypeName=
79+ 'Microsoft.SystemCenter.ExchangeConnector.ProcessEmailsWorkflow' and
80+ WriteActions/WriteAction/Subscription/WindowsWorkflowConfiguration/WorkflowParameters[
81+ WorkflowParameter[@Name='ClientID' and @Type='string'] and
82+ WorkflowParameter[@Name='TenantID' and @Type='string']
83+ ]
84+ ]" )
85+ $guid = ' ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$'
86+ $ExchangeOnlineConnectorsData = foreach ($r in $PotentialExchangeOnlineConnectorsData ) {
87+ $groups = $r.SelectNodes (" WriteActions/WriteAction/Subscription/WindowsWorkflowConfiguration/WorkflowParameters" )
88+ foreach ($g in $groups ) {
89+ $client = $g.SelectSingleNode (" WorkflowParameter[@Name='ClientID' and @Type='string']" )
90+ $tenant = $g.SelectSingleNode (" WorkflowParameter[@Name='TenantID' and @Type='string']" )
91+ if ($client -and $tenant -and
92+ $client.InnerText -match $guid -and
93+ $tenant.InnerText -match $guid ) { $r ; break }
94+ }
95+ }
96+ $ExchangeOnlineConnectorsData_Count = ($ExchangeOnlineConnectorsData | measure).Count
97+
98+ $ExchangeConnectors.SetAttribute (" Count_Enabled_ExchOnline" , $ExchangeOnlineConnectorsData_Count )
99+ $ExchangeConnectors.SetAttribute (" Count_Enabled_ExchOnPremise" , $ExchangeConnectorsEnabledCount - $ExchangeOnlineConnectorsData_Count )
100+ }
44101 # endregion
45102 }
46103}
0 commit comments