M365 Teams Watcher Node Discovery Data Source Module Type
Microsoft.SystemCenter.M365.DataSource.WatcherNodeDiscovery (DataSourceModuleType)
Data Source Module Type for Watcher Node Discovery.
Element properties:
Member Modules:
Overrideable Parameters:
Source Code:
<DataSourceModuleType ID="Microsoft.SystemCenter.M365.DataSource.WatcherNodeDiscovery" Accessibility="Internal" Batching="false">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TimeoutSeconds" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="IntervalSeconds" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="SyncTime" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ApplicationClientId" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="AzureADEndpoint" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="EnabledSyntheticTransactions" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ExchangeURL" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="GraphEndpoint" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="LicenseUser" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="LocationLatLong" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="LocationName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="M365EmailReceiver" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="M365EmailSender" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="RemainingLicensesErrorPercentageThreshold" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="RemainingLicensesWarningPercentageThreshold" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="SharePointDocumentLibrary" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="SharePointSite" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="SkuPartNumber" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TeamsChannelName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TeamsTeamName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TenantId" type="xsd:string"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="SyncTime" Selector="$Config/SyncTime$" ParameterType="string"/>
<OverrideableParameter ID="ApplicationClientId" Selector="$Config/ApplicationClientId$" ParameterType="string"/>
<OverrideableParameter ID="AzureADEndpoint" Selector="$Config/AzureADEndpoint$" ParameterType="string"/>
<OverrideableParameter ID="EnabledSyntheticTransactions" Selector="$Config/EnabledSyntheticTransactions$" ParameterType="string"/>
<OverrideableParameter ID="ExchangeURL" Selector="$Config/ExchangeURL$" ParameterType="string"/>
<OverrideableParameter ID="GraphEndpoint" Selector="$Config/GraphEndpoint$" ParameterType="string"/>
<OverrideableParameter ID="LicenseUser" Selector="$Config/LicenseUser$" ParameterType="string"/>
<OverrideableParameter ID="LocationLatLong" Selector="$Config/LocationLatLong$" ParameterType="string"/>
<OverrideableParameter ID="LocationName" Selector="$Config/LocationName$" ParameterType="string"/>
<OverrideableParameter ID="M365EmailReceiver" Selector="$Config/M365EmailReceiver$" ParameterType="string"/>
<OverrideableParameter ID="M365EmailSender" Selector="$Config/M365EmailSender$" ParameterType="string"/>
<OverrideableParameter ID="RemainingLicensesErrorPercentageThreshold" Selector="$Config/RemainingLicensesErrorPercentageThreshold$" ParameterType="int"/>
<OverrideableParameter ID="RemainingLicensesWarningPercentageThreshold" Selector="$Config/RemainingLicensesWarningPercentageThreshold$" ParameterType="int"/>
<OverrideableParameter ID="SharePointDocumentLibrary" Selector="$Config/SharePointDocumentLibrary$" ParameterType="string"/>
<OverrideableParameter ID="SharePointSite" Selector="$Config/SharePointSite$" ParameterType="string"/>
<OverrideableParameter ID="SkuPartNumber" Selector="$Config/SkuPartNumber$" ParameterType="string"/>
<OverrideableParameter ID="TeamsChannelName" Selector="$Config/TeamsChannelName$" ParameterType="string"/>
<OverrideableParameter ID="TeamsTeamName" Selector="$Config/TeamsTeamName$" ParameterType="string"/>
<OverrideableParameter ID="TenantId" Selector="$Config/TenantId$" ParameterType="string"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<DataSource ID="Scheduler" TypeID="System!System.Discovery.Scheduler">
<Scheduler>
<SimpleReccuringSchedule>
<Interval Unit="Seconds">$Config/IntervalSeconds$</Interval>
<SyncTime>$Config/SyncTime$</SyncTime>
</SimpleReccuringSchedule>
<ExcludeDates/>
</Scheduler>
</DataSource>
<ProbeAction ID="Probe" TypeID="Windows!Microsoft.Windows.PowerShellDiscoveryProbe">
<ScriptName>DiscoverM365WatcherNode.ps1</ScriptName>
<ScriptBody><Script>#=================================================================================
# DiscoverM365WatcherNode.ps1
#
# Discovers watcher nodes based on the existance of registry keys and creates
# class instances with the class properties based on overrides or default values.
#=================================================================================
param(
$sourceId,
$managedEntityId,
$computerName,
[string] $ApplicationClientId,
[string] $AzureADEndpoint,
[string] $EnabledSyntheticTransactions,
[string] $ExchangeURL,
[string] $GraphEndpoint,
[string] $LicenseUser,
[string] $LocationLatLong,
[string] $LocationName,
[string] $M365EmailReceiver,
[string] $M365EmailSender,
[int] $RemainingLicensesErrorPercentageThreshold,
[int] $RemainingLicensesWarningPercentageThreshold,
[string] $SharePointDocumentLibrary,
[string] $SharePointSite,
[string] $SkuPartNumber,
[string] $TeamsChannelName,
[string] $TeamsTeamName,
[string] $TenantId
)
# Constants
$ScriptName = 'DiscoverM365WatcherNode.ps1'
$eventId = 900
$eventSeverity = 0 # 0 = Informational, 1 = Error, 2 = Warning
$message = ''
$doLog = $true
# Gather script start time
$StartTime = Get-Date
# Gather who the script is running as
$whoami = whoami
# Load the MOMScript API and discovery propertybag
$api = New-Object -comObject 'MOM.ScriptAPI'
$discoveryData = $api.CreateDiscoveryData(0, $SourceId, $ManagedEntityId)
try
{
if( $LocationName -eq $null -or $LocationName -eq '' -or $LocationName.StartsWith( 'Override required' ) )
{
$message = "Microsoft 365 watcher node not discovered on $computerName due to a missing override for the LocationName property. Current value: $LocationName"
$eventSeverity = 0
$doLog = $false
}
else
{
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Microsoft.SystemCenter.M365.WatcherNodeApplication']$")
$instance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $computerName)
$instance.AddProperty("$MPElement[Name='Microsoft.SystemCenter.M365.WatcherNodeApplication']/ApplicationClientId$", $ApplicationClientId)
$instance.AddProperty("$MPElement[Name='Microsoft.SystemCenter.M365.WatcherNodeApplication']/AzureADEndpoint$", $AzureADEndpoint)
$instance.AddProperty("$MPElement[Name='Microsoft.SystemCenter.M365.WatcherNodeApplication']/EnabledSyntheticTransactions$", $EnabledSyntheticTransactions)
$instance.AddProperty("$MPElement[Name='Microsoft.SystemCenter.M365.WatcherNodeApplication']/ExchangeURL$", $ExchangeURL)
$instance.AddProperty("$MPElement[Name='Microsoft.SystemCenter.M365.WatcherNodeApplication']/GraphEndpoint$", $GraphEndpoint)
$instance.AddProperty("$MPElement[Name='Microsoft.SystemCenter.M365.WatcherNodeApplication']/LicenseUser$", $LicenseUser)
$instance.AddProperty("$MPElement[Name='Microsoft.SystemCenter.M365.WatcherNodeApplication']/LocationLatLong$", $LocationLatLong)
$instance.AddProperty("$MPElement[Name='Microsoft.SystemCenter.M365.WatcherNodeApplication']/LocationName$", $LocationName)
$instance.AddProperty("$MPElement[Name='Microsoft.SystemCenter.M365.WatcherNodeApplication']/M365EmailReceiver$", $M365EmailReceiver)
$instance.AddProperty("$MPElement[Name='Microsoft.SystemCenter.M365.WatcherNodeApplication']/M365EmailSender$", $M365EmailSender)
$instance.AddProperty("$MPElement[Name='Microsoft.SystemCenter.M365.WatcherNodeApplication']/RemainingLicensesErrorPercentageThreshold$", $RemainingLicensesErrorPercentageThreshold)
$instance.AddProperty("$MPElement[Name='Microsoft.SystemCenter.M365.WatcherNodeApplication']/RemainingLicensesWarningPercentageThreshold$", $RemainingLicensesWarningPercentageThreshold)
$instance.AddProperty("$MPElement[Name='Microsoft.SystemCenter.M365.WatcherNodeApplication']/SharePointDocumentLibrary$", $SharePointDocumentLibrary)
$instance.AddProperty("$MPElement[Name='Microsoft.SystemCenter.M365.WatcherNodeApplication']/SharePointSite$", $SharePointSite)
$instance.AddProperty("$MPElement[Name='Microsoft.SystemCenter.M365.WatcherNodeApplication']/SkuPartNumber$", $SkuPartNumber)
$instance.AddProperty("$MPElement[Name='Microsoft.SystemCenter.M365.WatcherNodeApplication']/TeamsChannelName$", $TeamsChannelName)
$instance.AddProperty("$MPElement[Name='Microsoft.SystemCenter.M365.WatcherNodeApplication']/TeamsTeamName$", $TeamsTeamName)
$instance.AddProperty("$MPElement[Name='Microsoft.SystemCenter.M365.WatcherNodeApplication']/TenantId$", $TenantId)
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $computerName)
$discoveryData.AddInstance($instance)
$message = "Microsoft 365 watcher node successfully discovered on $computerName. Also: "
if( $EnabledSyntheticTransactions.Contains('+M365MailFlow'))
{
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Microsoft.SystemCenter.M365.WatcherNodeApplication.M365MailFlow']$")
$instance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $computerName)
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $computerName)
$discoveryData.AddInstance($instance)
$message += ' M365MailFlow,'
}
if( $EnabledSyntheticTransactions.Contains('+HybridMailFlow'))
{
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Microsoft.SystemCenter.M365.WatcherNodeApplication.HybridMailFlow']$")
$instance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $computerName)
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $computerName)
$discoveryData.AddInstance($instance)
$message += ' HybridMailFlow,'
}
if( $EnabledSyntheticTransactions.Contains('+Teams'))
{
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Microsoft.SystemCenter.M365.WatcherNodeApplication.Teams']$")
$instance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $computerName)
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $computerName)
$discoveryData.AddInstance($instance)
$message += ' Teams,'
}
if( $EnabledSyntheticTransactions.Contains('+SharePoint'))
{
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Microsoft.SystemCenter.M365.WatcherNodeApplication.SharePoint']$")
$instance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $computerName)
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $computerName)
$discoveryData.AddInstance($instance)
$message += ' SharePoint,'
}
if( $EnabledSyntheticTransactions.Contains('+Networking'))
{
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Microsoft.SystemCenter.M365.WatcherNodeApplication.Networking']$")
$instance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $computerName)
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $computerName)
$discoveryData.AddInstance($instance)
$message += ' Networking,'
}
if( $EnabledSyntheticTransactions.Contains('+Licensing'))
{
# $SkuPartNumber can contain multiple SKU part numbers, separated by commas.
Foreach( $sku in $SkuPartNumber.Split(','))
{
$instance = $discoveryData.CreateClassInstance("$MPElement[Name='Microsoft.SystemCenter.M365.WatcherNodeApplication.Licensing']$")
$instance.AddProperty("$MPElement[Name='Microsoft.SystemCenter.M365.WatcherNodeApplication.Licensing']/SkuPartNumber$", $sku)
$instance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $computerName)
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $computerName)
$discoveryData.AddInstance($instance)
}
$message += ' Licensing,'
}
$message = $message.TrimEnd(',')
$message += '.'
}
}
catch
{
$message = "Unable to discover Microsoft 365 watcher node on $computerName. Reason: " + $_.Exception.Message
$eventSeverity = 1
}
#Output Discovery Propertybag
$discoveryData
# Return Discovery Bag to the command line for testing (does not work from ISE):
# $api.Return($discoveryData)
if( $doLog )
{
#Log an event for script ending, total execution time and result.
$EndTime = Get-Date
$ScriptTime = ($EndTime - $StartTime).TotalSeconds
$api.LogScriptEvent($ScriptName,$eventId,$eventSeverity,"Script has completed. Run as ($whoami). Runtime was ($ScriptTime) seconds. Result: $message")
}
</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>sourceId</Name>
<Value>$MPElement$</Value>
</Parameter>
<Parameter>
<Name>managedEntityId</Name>
<Value>$Target/Id$</Value>
</Parameter>
<Parameter>
<Name>computerName</Name>
<Value>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$</Value>
</Parameter>
<Parameter>
<Name>ApplicationClientId</Name>
<Value>$Config/ApplicationClientId$</Value>
</Parameter>
<Parameter>
<Name>AzureADEndpoint</Name>
<Value>$Config/AzureADEndpoint$</Value>
</Parameter>
<Parameter>
<Name>EnabledSyntheticTransactions</Name>
<Value>$Config/EnabledSyntheticTransactions$</Value>
</Parameter>
<Parameter>
<Name>ExchangeURL</Name>
<Value>$Config/ExchangeURL$</Value>
</Parameter>
<Parameter>
<Name>GraphEndpoint</Name>
<Value>$Config/GraphEndpoint$</Value>
</Parameter>
<Parameter>
<Name>LicenseUser</Name>
<Value>$Config/LicenseUser$</Value>
</Parameter>
<Parameter>
<Name>LocationLatLong</Name>
<Value>$Config/LocationLatLong$</Value>
</Parameter>
<Parameter>
<Name>LocationName</Name>
<Value>$Config/LocationName$</Value>
</Parameter>
<Parameter>
<Name>M365EmailReceiver</Name>
<Value>$Config/M365EmailReceiver$</Value>
</Parameter>
<Parameter>
<Name>M365EmailSender</Name>
<Value>$Config/M365EmailSender$</Value>
</Parameter>
<Parameter>
<Name>RemainingLicensesErrorPercentageThreshold</Name>
<Value>$Config/RemainingLicensesErrorPercentageThreshold$</Value>
</Parameter>
<Parameter>
<Name>RemainingLicensesWarningPercentageThreshold</Name>
<Value>$Config/RemainingLicensesWarningPercentageThreshold$</Value>
</Parameter>
<Parameter>
<Name>SharePointDocumentLibrary</Name>
<Value>$Config/SharePointDocumentLibrary$</Value>
</Parameter>
<Parameter>
<Name>SharePointSite</Name>
<Value>$Config/SharePointSite$</Value>
</Parameter>
<Parameter>
<Name>SkuPartNumber</Name>
<Value>$Config/SkuPartNumber$</Value>
</Parameter>
<Parameter>
<Name>TeamsChannelName</Name>
<Value>$Config/TeamsChannelName$</Value>
</Parameter>
<Parameter>
<Name>TeamsTeamName</Name>
<Value>$Config/TeamsTeamName$</Value>
</Parameter>
<Parameter>
<Name>TenantId</Name>
<Value>$Config/TenantId$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>300</TimeoutSeconds>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="Probe">
<Node ID="Scheduler"/>
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Discovery.Data</OutputType>
</DataSourceModuleType>