ProvedordeDescoberta de RegradoSPHA

Microsoft.SharePoint.2013.SPHARule.DiscoveryProvider (DataSourceModuleType)

ProvedordeDescoberta para descobrir Regra do SPHA (Analisador de Estado do SharePoint).

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsMicrosoft.SharePoint.AdminAccount
OutputTypeSystem.Discovery.Data

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource Microsoft.SharePoint.2013.CommandExecuterDiscoveryDataSource Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
IntervalSecondsint$Config/IntervalSeconds$IntervaloemSegundosPropriedade IntervaloemSegundos de ProvedordeDescoberta para Regra do SPHA (Analisador de Estado do SharePoint). A frequência em segundos com que essa Descoberta será executada; deve ser longa o bastante para evitar falha de descoberta devido a recursos conflitantes.
SyncTimestring$Config/SyncTime$TempoSincPropriedade TempoSinc (hora de início) do ProvedordeDescoberta para Regra do SPHA (Analisador de Estado do SharePoint). TempoSinc é um valor de cadeia de caracteres no formato “HH:mm”. A hora de TempoSinc, IntervaloemSegundos e Importação de Pacote de Gerenciamento, juntos, determina o tempo de execução exato de um fluxo de trabalho específico. Por exemplo, se IntervaloemSegundos = 21600 (6 horas) e TempoSinc = "01:15", o tempo de execução possível do fluxo de trabalho será 1:15AM, 7:15AM, 1:15PM, 7:15PM; se o Pacote de Gerenciamento for importado após 1:15AM, mas antes de 7:15AM, ele começará às 7:15AM; se o Pacote de Gerenciamento for importado após 1:15PM, mas antes de 7:15PM, ele começará às 7:15PM. Entretanto, devido a outros fatores – por exemplo, atraso de rede – a hora de início real ainda poderá variar.
TimeoutSecondsint$Config/TimeoutSeconds$TempoLimiteemSegundosPropriedade TempoLimiteemSegundos de ProvedordeDescoberta para Regra do SPHA (Analisador de Estado do SharePoint). O valor TempoLimite deve ser longo o bastante para a conclusão da Descoberta do objeto necessário. Deve ser menor que IntervaloemSegundos.
DebugTracebool$Config/DebugTrace$RastreamentodeDepuraçãoPropriedade RastreamentodeDepuração do Provedor de Descoberta de Regra do SPHA (Analisador de Estado do SharePoint). O módulo Descoberta gravará o rastreamento de depuração no Log de Eventos do Windows se este valor estiver definido como verdadeiro.

Source Code:

<DataSourceModuleType ID="Microsoft.SharePoint.2013.SPHARule.DiscoveryProvider" Accessibility="Internal" RunAs="WSS!Microsoft.SharePoint.AdminAccount">
<Configuration>
<xsd:element name="ComputerName" type="xsd:string"/>
<xsd:element name="IntervalSeconds" type="xsd:integer"/>
<xsd:element name="SyncTime" type="xsd:string"/>
<xsd:element name="TimeoutSeconds" type="xsd:integer"/>
<xsd:element name="DebugTrace" type="xsd:boolean"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="SyncTime" Selector="$Config/SyncTime$" ParameterType="string"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
<OverrideableParameter ID="DebugTrace" Selector="$Config/DebugTrace$" ParameterType="bool"/>
</OverrideableParameters>
<ModuleImplementation>
<Composite>
<MemberModules>
<DataSource ID="DS" TypeID="Microsoft.SharePoint.2013.CommandExecuterDiscoveryDataSource">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<SyncTime>$Config/SyncTime$</SyncTime>
<ApplicationName/>
<WorkingDirectory/>
<CommandLine>powershell.exe -NoLogo -NoProfile -Noninteractive "$ep = get-executionpolicy; set-executionpolicy remotesigned; &amp; '$file/WSSBPADiscovery.ps1$' '$MPElement$' '$Target/Id$' '$Config/ComputerName$' '$Config/DebugTrace$'</CommandLine>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
<RequireOutput>true</RequireOutput>
<Files>
<File>
<Name>WSSStrings.ps1</Name>
<Contents><Script>$global:EventLog_Fail_Create_Discovery_Package = "Failed to create Discovery transmission package.";
$global:EventLog_Fail_Return_Discovery_Package = "Failed to return Discovery transmission package.";
$global:EventLog_Fail_Create_Discovery_ScriptAPI = "Failed to initiate MOM.ScriptAPI object.";
$global:EventLog_Fail_Create_Class = "Failed to create {0} class instance.";
$global:EventLog_Fail_Create_Relationship = "Failed to create {0} relationship instance.";
$global:EventLog_Fail_LoadBalancer_Operation = "Addresses for this application may not have been fetched yet.";

$global:EventLog_Exit_On_NonExist = "This machine does not have SharePoint installed."
$global:EventLog_Fail_On_Error = "{0} Discovery/Monitoring script continues under this error! ";
$global:EventLog_Exit_On_Error = "{0} Discovery/Monitoring script was terminated! ";

$global:EventLog_Format = @"
Current User: {0}
Current PID: {1}
InvocationInfo.MyCommand: {2}
InvocationInfo.ScriptLineNumber: {3}
InvocationInfo.OffsetInLine: {4}
InvocationInfo.ScriptName: {5}
InvocationInfo.Line: {6}
InvocationInfo.PositionMessage: {7}
InvocationInfo.InvocationName: {8}
InvocationInfo.PipelineLength: {9}
InvocationInfo.PipelinePosition: {10}
"@;

$global:EventLog_Template = "[{0} in Discovery/Monitoring script] {1} {2}";

$global:EventLog_Debug_StartedArgs = "[Debug] {0} Started. Args[]={1}, {2}, {3}, {4}.";
$global:EventLog_Debug_MajorServer = "[Debug] This is the major server detected by {0}.";

$global:EventLog_Fail_Identify_Farm = "Cannot identify which SharePoint farm this server is associated with. Check the management pack guide for troubleshooting information.";
$global:EventLog_Fail_Retrieve_Farm_And_Local = "Failed on retrieving information for SharePoint farm and Sharepoint local machine. Check the management pack guide for troubleshooting information.";
$global:EventLog_Fail_Retrieve_OM_Value = "Failed on retrieving values from SharePoint object model.";
$global:EventLog_Fail_Retrieve_Service = "Failed on retrieving {0} service from SharePoint farm {1}.";
$global:EventLog_Fail_Retrieve_Object = "Failed to find {0} in SharePoint object model.";

$global:DisplayName_ServerGroup = "Server Group";
$global:DisplayName_ServiceGroup = "Service Group";
$global:DisplayName_WebApplicationGroup = "Web Application Group";
$global:DisplayName_SharedServiceGroup = "Shared Service Group";
$global:DisplayName_SharedProxyGroup = "Shared Service Proxy Group";
$global:DisplayName_ProxyClient = "Proxy Client ({0})";
$global:DisplayName_TimerJobs = "Timer Jobs";
$global:DisplayName_HostCollection = "Host Collection";
$global:DisplayName_DatabaseCollection = "Database Collection";

$global:DisplayName_SPTrace = "SPTraceV4";
$global:DisplayName_WindowsTracingService = "SharePoint Tracing Service";
$global:DisplayName_AdminWord = " - Admin";
</Script></Contents>
</File>
<File>
<Name>WSSDiscoveryLibrary.ps1</Name>
<Contents><Script>$error.Clear();
$ErrorActionPreference = "SilentlyContinue";

$global:EventObject = New-Object Diagnostics.EventLog
$global:EventObject.Source = "Operations Manager"

function global:Write-Event ([string] $LogContent, $LogType = [Diagnostics.EventLogEntryType]::Information)
{
if ($error)
{
$error.Clear()
$LogType = [Diagnostics.EventLogEntryType]::Error
}

$EventObject.WriteEntry($LogContent, $LogType)
}

function global:LogScriptTime($InvocationObj)
{
$dtEnd = [DateTime]::Now

$msg = @"
[Debug] {0} ended.
Current User: {1}
Current PID: {2}
start time: {3}
stop time: {4}
time taken: {5}
"@ -f $InvocationObj.MyCommand,
[Environment]::UserName,
$pid,
$dtStart,
$dtEnd,
(New-TimeSpan $dtStart $dtEnd).TotalMilliseconds

Write-Event $msg
}

.\WSSStrings.ps1

$global:Arguments = $Args;

$global:Farm = $null;
$global:LocalServer = $null;
$global:DiscData = $null;
$global:Port = "_port";
$global:Http = "_http";

function global:Get-Farm()
{
if ($global:Farm -eq $null)
{

$global:Farm = [Microsoft.SharePoint.Administration.SPFarm]::Local;
}
}

function global:Get-LocalServer()
{
if ($global:LocalServer -eq $null)
{

$global:LocalServer = [Microsoft.SharePoint.Administration.SPServer]::Local;
}
}

function global:Get-ServiceProxy([string] $ClassType)
{
Get-Farm;
foreach ($ServiceProxy in $global:Farm.ServiceProxies)
{
if ($ClassType.ToLower() -eq $ServiceProxy.GetType().FullName.ToLower())
{
return $ServiceProxy;
}
}
return $null;
}

function global:Get-Service([string] $ClassType)
{
Get-Farm;
foreach ($Service in $global:Farm.Services)
{
if ($ClassType.ToLower() -eq $Service.GetType().FullName.ToLower())
{
return $Service;
}
}
return $null;
}

function global:Get-ServiceEx([string] $ClassType, [string] $Name)
{
Get-Farm;
foreach ($Service in $global:Farm.Services)
{
if ($ClassType.ToLower() -eq $ServiceInstance.GetType().FullName.ToLower())
{
if ($Name.ToLower() -eq $ServiceInstance.Name.ToLower())
{
return $ServiceInstance;
}
}
}
return $null;
}

function global:Get-ServiceInstance([string] $ClassType)
{
Get-LocalServer;

if (! $ClassType.EndsWith("Instance"))
{
$ClassType += "Instance";
}

foreach ($ServiceInstance in $global:LocalServer.ServiceInstances)
{
if ($ClassType.ToLower() -eq $ServiceInstance.GetType().FullName.ToLower())
{
return $ServiceInstance;
}
}
return $null;
}

function global:Get-ServiceInstanceEx([string] $ClassType, [string] $Name)
{
Get-LocalServer;

if (! $ClassType.EndsWith("Instance"))
{
$ClassType += "Instance";
}

foreach ($ServiceInstance in $global:LocalServer.ServiceInstances)
{
if ($ClassType.ToLower() -eq $ServiceInstance.GetType().FullName.ToLower())
{
if ($Name.ToLower() -eq $ServiceInstance.Name.ToLower())
{
return $ServiceInstance;
}
}
}
return $null;
}

function global:Create-DiscoveryData()
{
if ($global:DiscData -eq $null)
{
$global:DiscData = $global:MomScriptAPIObject.CreateDiscoveryData(0, $global:Arguments[0], $global:Arguments[1]);
Handle-Errors($global:EventLog_Fail_Create_Discovery_Package, $true, $false);

$global:HealthSvc = $global:DiscData.CreateClassInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthService']$");
$global:HealthSvc.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $global:ComputerName);
Handle-Errors($global:EventLog_Fail_Create_Class -f "Microsoft.SystemCenter.HealthService");
}
return $global:DiscData;
}

function global:Deliver-DiscoveryData([Object] $DiscData)
{
$global:MomScriptAPIObject.Return($DiscData);
Handle-Errors($global:EventLog_Fail_Return_Discovery_Package, $true, $false);
$DiscData = $null;
}

function global:IsMainServer([System.Boolean] $UseLastServer)
{
$Servers = $global:Farm.Servers;

if ($UseLastServer)
{
$Count = $Servers.Count;
$ServerArray = new-object string[][] $Count,2;
$Index = 0;

foreach ($Server in $Servers)
{
$ServerArray[$Index][0] = $Server.Name;
$ServerArray[$Index++][1] = $Server.Role.ToString();
}

for ($Index--; $Index -ge 0; $Index--)
{

if ($ServerArray[$Index][1] -ne "Invalid")
{
return ($ServerArray[$Index][0] -eq $global:LocalServer.Name);
}
}
}
else
{
foreach ($Server in $Servers)
{

if ($Server.Role -ne "Invalid")
{
return ($Server.Name -eq $global:LocalServer.Name);
}
}
}

return $false;
}

function global:Release-Resources()
{
$global:HashData = $null;
$global:DiscData = $null;
$global:HealthSvc = $null;
$global:MomScriptAPIObject = $null;

$global:WSSAssembly = $null;

$global:EventObject = $null;
$global:EventAssembly = $null;
}

function global:Handle-Errors([System.Object] $Arguments)
{
if (! $error)
{
return;
}

$ErrMsg = "";
$IsExit = $true;
$IsReturn = $true;
$IsLog = $true;

if ("System.String" -eq $Arguments.GetType().FullName)
{
$ErrMsg = $Arguments;
}
else
{
$ErrMsg = $Arguments[0];
$IsExit = $Arguments[1];
if ($Arguments.Count -gt 2)
{
$IsReturn = $Arguments[2];
}
if ("" -eq $ErrMsg)
{
$IsLog = $false;
}
}

if ($IsLog.Equals($true))
{
$ErrorString = "";
if ($IsExit.Equals($false))
{
$ErrorString = $global:EventLog_Fail_On_Error -f $ErrMsg;
}
else
{
$ErrorString = $global:EventLog_Exit_On_Error -f $ErrMsg;
}

$Exception = $error[$error.Count - 1];
if ($Exception.InvocationInfo -ne $null)
{
$ErrorString += ($global:EventLog_Format -f [Environment]::UserName, $pid, $Exception.InvocationInfo.MyCommand,
$Exception.InvocationInfo.ScriptLineNumber, $Exception.InvocationInfo.OffsetInLine, $Exception.InvocationInfo.ScriptName,
$Exception.InvocationInfo.Line, $Exception.InvocationInfo.PositionMessage, $Exception.InvocationInfo.InvocationName,
$Exception.InvocationInfo.PipelineLength, $Exception.InvocationInfo.PipelinePosition);
}

if ($null -ne $Exception.Exception)
{
$Exception = $Exception.Exception;
}
$InnerException = $Exception;
if ($null -ne $Exception.InnerException)
{
$InnerException = $Exception.InnerException;
}

$global:EventObject.WriteEntry(($global:EventLog_Template -f $InnerException.GetType().FullName, $ErrorString, $Exception.Message), [System.Diagnostics.EventLogEntryType]::Error);
}

if ($IsExit.Equals($true))
{
if ($IsReturn.Equals($true))
{
Deliver-DiscoveryData($global:DiscData);
}
Release-Resources;
break;
}

$error.Clear();
}

function global:GetDebugSetting($DebugTrace)
{

if ($DebugTrace.ToUpper() -eq "TRUE")
{
$global:Debug = $True;
}
else
{
$global:Debug = $False;
}

}

$global:MomScriptAPIObject = new-object -comObject "MOM.ScriptAPI";
Handle-Errors($global:EventLog_Fail_Create_Discovery_ScriptAPI, $true, $false);

$global:WSSAssembly = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint");
if ($null -eq $global:WSSAssembly)
{
throw $global:EventLog_Exit_On_NonExist;
}
Handle-Errors("", $true, $false);

if ($WSSAssembly.GetName().Version.Major -ne 15)
{
Release-Resources;
break;
}

$global:WSSConfig = "Microsoft.SharePoint.Administration.SPConfigurationDatabase";
$global:WSSAdmin = "Microsoft.SharePoint.Administration.SPWebService";
$global:SPAdmin = "Microsoft.SharePoint.Administration.SPAdministrationService";
$global:SPSearch = "Microsoft.SharePoint.Search.Administration.SPSearchService";
$global:SPIncomingMail = "Microsoft.SharePoint.Administration.SPIncomingEmailService";
$global:SPHelpSearch = "Microsoft.SharePoint.Search.Administration.SPSearchService";
$global:SPTimer = "Microsoft.SharePoint.Administration.SPTimerService";
$global:SPWebApp = "Microsoft.SharePoint.Administration.SPWebService";
$global:SPUserCode = "Microsoft.SharePoint.Administration.SPUserCodeService";
$global:SPDatabase = "Microsoft.SharePoint.Administration.SPDatabaseService";

$global:SPTopology = "Microsoft.SharePoint.SPTopologyWebService";
$global:SPUsage = "Microsoft.SharePoint.Administration.SPUsageService";
$global:SPBDC = "Microsoft.SharePoint.BusinessData.SharedService.BdcService";
$global:SPSecurityToken = "Microsoft.SharePoint.Administration.Claims.SPSecurityTokenService";

</Script></Contents>
</File>
<File>
<Name>WSSBPADiscovery.ps1</Name>
<Contents><Script>.\WSSDiscoveryLibrary.ps1 $Args[0] $Args[1]

GetDebugSetting $Args[3]

if ($global:Debug) { $global:dtStart = [DateTime]::Now }
if ($global:Debug) { Write-Event($global:EventLog_Debug_StartedArgs -f $MyInvocation.MyCommand, $Args[0], $Args[1], $Args[2], $Args[3]) }

$global:ComputerName = $Args[2]
$global:DiscData = Create-DiscoveryData

Get-Farm
Get-LocalServer

if ($global:Farm)
{
$global:FarmID = $global:LocalServer.Farm.Id.ToString()

.\WSSBPARuleDiscoveryWrapper.ps1
}

Deliver-DiscoveryData($global:DiscData)

if ($global:Debug) { LogScriptTime($MyInvocation) }

Release-Resources
</Script></Contents>
</File>
<File>
<Name>WSSBPARuleDiscoveryWrapper.ps1</Name>
<Contents><Script>if ($global:Farm)
{
$MainServer = IsMainServer($false)

if ($MainServer)
{
if ($global:Debug) { $global:EventLog_Debug_MajorServer -f $MyInvocation.MyCommand }

.\WSSBPARuleDiscovery.ps1
}
}

</Script></Contents>
</File>
<File>
<Name>WSSBPARuleDiscovery.ps1</Name>
<Contents><Script>$HealthRuleQuery = new-object Microsoft.SharePoint.SPQuery
$HealthRuleQuery.ViewFields = "&lt;FieldRef Name='Title'/&gt;&lt;FieldRef Name='HealthRuleScope'/&gt;&lt;FieldRef Name='HealthRuleCheckEnabled'/&gt;&lt;FieldRef Name='HealthReportCategory'/&gt;&lt;FieldRef Name='HealthRuleType'/&gt;&lt;FieldRef Name='HealthRuleSchedule'/&gt;&lt;FieldRef Name='HealthRuleService'/&gt;&lt;FieldRef Name='HealthRuleAutoRepairEnabled'/&gt;"
$HealthRuleQuery.Query = "&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name='HealthRuleCheckEnabled'/&gt;&lt;Value Type='String'&gt;1&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;"
$HealthRules = [Microsoft.SharePoint.Administration.SPAdministrationWebApplication]::Local.HealthRules
if (!$HealthRules)
{
$ErrMsg = @"
Error in {0}:
Failed to get SharePoint Health Rules.
Make sure user {1} have enough permission or SharePoint is configured correctly and the database server is running.
Other issues might also cause this failure. Please see Microsoft SharePoint Foundation 2013 Management Pack Guide.docx for more information.
"@ -f $MyInvocation.MyCommand, [Environment]::UserName
$EventObject.WriteEntry($ErrMsg, [System.Diagnostics.EventLogEntryType]::Warning)
break;
}
$HealthRules = $HealthRules.GetItems($HealthRuleQuery)
Handle-Errors("Error loading Microsoft SharePoint Foundation 2013 HealthRules.")
if (!$HealthRules)
{
break
}

$RuleLocCategories = @{}
$RuleLocCategories["Availability"] = [Microsoft.SharePoint.Administration.Health.SPHealthAnalyzer]::GetLocalizedCategory([Microsoft.SharePoint.Administration.Health.SPHealthCategory]::Availability)
$RuleLocCategories["Configuration"] = [Microsoft.SharePoint.Administration.Health.SPHealthAnalyzer]::GetLocalizedCategory([Microsoft.SharePoint.Administration.Health.SPHealthCategory]::Configuration)
$RuleLocCategories["Performance"] = [Microsoft.SharePoint.Administration.Health.SPHealthAnalyzer]::GetLocalizedCategory([Microsoft.SharePoint.Administration.Health.SPHealthCategory]::Performance)
$RuleLocCategories["Security"] = [Microsoft.SharePoint.Administration.Health.SPHealthAnalyzer]::GetLocalizedCategory([Microsoft.SharePoint.Administration.Health.SPHealthCategory]::Security)
$RuleLocCategories["Custom"] = [Microsoft.SharePoint.Administration.Health.SPHealthAnalyzer]::GetLocalizedCategory([Microsoft.SharePoint.Administration.Health.SPHealthCategory]::Custom)
$RuleLocCategories["System"] = [Microsoft.SharePoint.Administration.Health.SPHealthAnalyzer]::GetLocalizedCategory([Microsoft.SharePoint.Administration.Health.SPHealthCategory]::System)

$SPHARuleSubGroupNames = @( "Scope: Run on Any Server", "Scope: Run on All Servers" )
$SPHARuleSubGroupLocNames = @{}
$SPHARuleSubGroupLocNames["Scope: Run on Any Server"] = [Microsoft.SharePoint.Administration.Health.SPHealthAnalyzer]::GetLocalizedScope([Microsoft.SharePoint.Administration.Health.SPHealthCheckScope]::Any)
$SPHARuleSubGroupLocNames["Scope: Run on All Servers"] = [Microsoft.SharePoint.Administration.Health.SPHealthAnalyzer]::GetLocalizedScope([Microsoft.SharePoint.Administration.Health.SPHealthCheckScope]::All)
foreach ($SPHARuleSubGroupName in $SPHARuleSubGroupNames)
{

$SPHARuleSubGroup = $DiscData.CreateClassInstance("$MPElement[Name='Microsoft.SharePoint.2013.SPHARuleSubGroup']$")
$SPHARuleSubGroup.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $SPHARuleSubGroupName)
$SPHARuleSubGroup.AddProperty("$MPElement[Name='WSS!Microsoft.SharePoint.SPHARuleSubGroup']/FarmID$", $FarmID)
$SPHARuleSubGroup.AddProperty("$MPElement[Name='WSS!Microsoft.SharePoint.SPHARuleSubGroup']/RuleSubGroupName$", $SPHARuleSubGroupName)

foreach ($HealthRule in $HealthRules)
{
if (($SPHARuleSubGroupLocNames[$SPHARuleSubGroupName] -eq $HealthRule["HealthRuleScope"]) -and ($HealthRule["HealthReportCategory"] -ne $RuleLocCategories["System"]))
{

$SPHARule = $null

$SPHARuleSubGroupRuleRel = $null
switch ($HealthRule["HealthReportCategory"])
{
$RuleLocCategories["Availability"]
{
$SPHARule = $DiscData.CreateClassInstance("$MPElement[Name='Microsoft.SharePoint.2013.SPHARule.Availability']$")
$SPHARuleSubGroupRuleRel = $DiscData.CreateRelationshipInstance("$MPElement[Name='WSS!Microsoft.SharePoint.SPHARuleSubGroup.Contains.SPHARule.Availability']$")
}
$RuleLocCategories["Configuration"]
{
$SPHARule = $DiscData.CreateClassInstance("$MPElement[Name='Microsoft.SharePoint.2013.SPHARule.Configuration']$")
$SPHARuleSubGroupRuleRel = $DiscData.CreateRelationshipInstance("$MPElement[Name='WSS!Microsoft.SharePoint.SPHARuleSubGroup.Contains.SPHARule.Configuration']$")
}
$RuleLocCategories["Performance"]
{
$SPHARule = $DiscData.CreateClassInstance("$MPElement[Name='Microsoft.SharePoint.2013.SPHARule.Performance']$")
$SPHARuleSubGroupRuleRel = $DiscData.CreateRelationshipInstance("$MPElement[Name='WSS!Microsoft.SharePoint.SPHARuleSubGroup.Contains.SPHARule.Performance']$")
}
$RuleLocCategories["Security"]
{
$SPHARule = $DiscData.CreateClassInstance("$MPElement[Name='Microsoft.SharePoint.2013.SPHARule.Security']$")
$SPHARuleSubGroupRuleRel = $DiscData.CreateRelationshipInstance("$MPElement[Name='WSS!Microsoft.SharePoint.SPHARuleSubGroup.Contains.SPHARule.Security']$")
}
$RuleLocCategories["Custom"]
{
$SPHARule = $DiscData.CreateClassInstance("$MPElement[Name='Microsoft.SharePoint.2013.SPHARule.Custom']$")
$SPHARuleSubGroupRuleRel = $DiscData.CreateRelationshipInstance("$MPElement[Name='WSS!Microsoft.SharePoint.SPHARuleSubGroup.Contains.SPHARule.Custom']$")
}
Default
{
$SPHARule = $DiscData.CreateClassInstance("$MPElement[Name='Microsoft.SharePoint.2013.SPHARule.Custom']$")
$SPHARuleSubGroupRuleRel = $DiscData.CreateRelationshipInstance("$MPElement[Name='WSS!Microsoft.SharePoint.SPHARuleSubGroup.Contains.SPHARule.Custom']$")
}
}
$HealthRuleType = $HealthRule["HealthRuleType"].SubString(0, $HealthRule["HealthRuleType"].IndexOf(","))
$SPHARule.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $HealthRule.Title)
$SPHARule.AddProperty("$MPElement[Name='WSS!Microsoft.SharePoint.SPHARule']/FarmID$", $FarmID)
$SPHARule.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $ComputerName)
$SPHARule.AddProperty("$MPElement[Name='WSS!Microsoft.SharePoint.SPHARule']/HostServer$", $ComputerName)
$SPHARule.AddProperty("$MPElement[Name='WSS!Microsoft.SharePoint.SPHARule']/RuleType$", $HealthRuleType)
$SPHARule.AddProperty("$MPElement[Name='WSS!Microsoft.SharePoint.SPHARule']/RuleName$", $HealthRule.Title)
$SPHARule.AddProperty("$MPElement[Name='WSS!Microsoft.SharePoint.SPHARule']/RuleSchedule$", $HealthRule["HealthRuleSchedule"])
$SPHARule.AddProperty("$MPElement[Name='WSS!Microsoft.SharePoint.SPHARule']/RuleService$", $HealthRule["HealthRuleService"])
$SPHARule.AddProperty("$MPElement[Name='WSS!Microsoft.SharePoint.SPHARule']/RuleScope$", $HealthRule["HealthRuleScope"])
$SPHARule.AddProperty("$MPElement[Name='WSS!Microsoft.SharePoint.SPHARule']/RuleCategory$", $HealthRule["HealthReportCategory"])
$SPHARule.AddProperty("$MPElement[Name='WSS!Microsoft.SharePoint.SPHARule']/RuleAutoRepairEnabled$", $HealthRule["HealthRuleAutoRepairEnabled"])

$DiscData.AddInstance($SPHARule)
Handle-Errors("Failed to create SPHARule class instance.", $false)

$SPHARuleSubGroupRuleRel.Source = $SPHARuleSubGroup
$SPHARuleSubGroupRuleRel.Target = $SPHARule
$DiscData.AddInstance($SPHARuleSubGroupRuleRel)
Handle-Errors("Failed to create SPHARuleSubGroup.Contains.SPHARule relationship instance.", $false)
}
}
}

</Script></Contents>
</File>
</Files>
</DataSource>
</MemberModules>
<Composition>
<Node ID="DS"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Discovery.Data</OutputType>
</DataSourceModuleType>