Módulo de Alerta de Vencimento do Certificado OpsMgr

Microsoft.SystemCenter.SCOM.Certificate.Expiry.DataSourceModule (DataSourceModuleType)

Esse módulo gera um alerta para o Vencimento do Certificado OpsMgr.

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.PropertyBagData

Member Modules:

ID Module Type TypeId RunAs 
Scheduler DataSource System.Scheduler Default
Probe ProbeAction Microsoft.Windows.PowerShellPropertyBagProbe Default

Overrideable Parameters:

IDParameterTypeSelector
TimeoutSecondsint$Config/TimeoutSeconds$
AlertBeforeNumDaysint$Config/AlertBeforeNumDays$
IntervalSecondsint$Config/IntervalSeconds$

Source Code:

<DataSourceModuleType ID="Microsoft.SystemCenter.SCOM.Certificate.Expiry.DataSourceModule" Accessibility="Internal" Batching="false">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" type="xsd:integer" name="TimeoutSeconds"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" type="xsd:integer" name="AlertBeforeNumDays"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" type="xsd:integer" name="IntervalSeconds"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
<OverrideableParameter ID="AlertBeforeNumDays" Selector="$Config/AlertBeforeNumDays$" ParameterType="int"/>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<DataSource ID="Scheduler" TypeID="System!System.Scheduler">
<Scheduler>
<SimpleReccuringSchedule>
<Interval Unit="Seconds">$Config/IntervalSeconds$</Interval>
</SimpleReccuringSchedule>
<ExcludeDates/>
</Scheduler>
</DataSource>
<ProbeAction ID="Probe" TypeID="Windows!Microsoft.Windows.PowerShellPropertyBagProbe">
<ScriptName>ScomCertificateExpiryAlert.ps1</ScriptName>
<ScriptBody><Script>
param($alertBeforeNumDays)
if($alertBeforeNumDays -eq $null -or $alertBeforeNumDays -eq "")
{
$alertBeforeNumDays = 7
}
$momAPI = new-object -comObject MOM.ScriptAPI
$thumbprint = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Machine Settings"
$thumbprint = $thumbprint.ChannelCertificateHash
$todaysDate = Get-Date
$expirationDate = (Get-ChildItem -path cert:\LocalMachine\My | where { $_.Thumbprint -eq $thumbprint }).NotAfter.Date
$daysToExpire = (NEW-TIMESPAN &#x2013;Start $todaysDate &#x2013;End $expirationDate).Days
$doGenerateAlert = "false"
if($daysToExpire -ne $null -and $daysToExpire -ne "" -and $daysToExpire -le $alertBeforeNumDays)
{
$doGenerateAlert = "true"
}else{
$doGenerateAlert = "false";
}

$oBag = $momAPI.CreatePropertyBag()
$oBag.AddValue("GenerateAlert", $doGenerateAlert)
$oBag.AddValue("ExpiryDays", $daysToExpire)
$oBag
</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>alertBeforeNumDays</Name>
<Value>$Config/AlertBeforeNumDays$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="Probe">
<Node ID="Scheduler"/>
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
</DataSourceModuleType>