Modul för varning om att OpsMgr-certifikat håller på att gå ut
Microsoft.SystemCenter.SCOM.Certificate.Expiry.DataSourceModule (DataSourceModuleType)
Den här modulen skapar en varning om att OpsMgr-certifikatet håller på att gå ut.
Element properties:
Member Modules:
Overrideable Parameters:
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 –Start $todaysDate –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>