Schrijfactie voor het inschakelen van de service voor externe gegevensbronnen van System Center Operations Manager

Microsoft.SystemCenter.EnableService (WriteActionModuleType)

Schrijfactie voor het openen van de firewallpoort en het inschakelen van de service voor externe gegevensbronnen van System Center Operations Manager

Element properties:

TypeWriteActionModuleType
IsolationAny
AccessibilityPublic
RunAsDefault
InputTypeSystem.BaseData

Member Modules:

ID Module Type TypeId RunAs 
EnableService WriteAction Microsoft.Windows.PowerShellWriteAction Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
TimeoutSecondsint$Config/TimeoutSeconds$TimeoutSeconds

Source Code:

<WriteActionModuleType ID="Microsoft.SystemCenter.EnableService" Accessibility="Public" Batching="false">
<Configuration>
<xsd:element name="TimeoutSeconds" type="xsd:integer" minOccurs="0"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="TimeoutSeconds" ParameterType="int" Selector="$Config/TimeoutSeconds$"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<WriteAction ID="EnableService" TypeID="Windows!Microsoft.Windows.PowerShellWriteAction">
<ScriptName>EnableService.ps1</ScriptName>
<ScriptBody><Script>
$FirewallRuleName = "System Center Operations Manager External DataSource Service"
$ServiceName = "OMED"
try{
$Service = Get-Service -Name $ServiceName -ErrorAction Stop
}Catch{
Write-Host "OMED Service is not Installed."
exit
}
if($Service.Status -ne "Running")
{
$Port = 8886
Remove-NetFirewallRule -DisplayName $FirewallRuleName
Write-Host "Port" $Port "cleaned"
try {
New-NetFirewallRule -DisplayName $FirewallRuleName -Direction Inbound -Protocol TCP -LocalPort $Port -Enabled true -Action Allow
Write-Host "Port" $Port "opened"
}Catch
{
Write-Host "Port" $Port "opening failed"
Write-Host "Open the firewall port manually, and start the OMED service."
exit
}
Set-Service $ServiceName -StartupType "Automatic"
Write-Host "OMED Service changed to automatic"
$Service = Get-Service -Name $ServiceName
Write-Host "Starting OMED service."
Start-Service $ServiceName
$TimeOut = 10000
Start-Sleep -m $TimeOut
$Service = Get-Service -Name $ServiceName
if ($Service.Status -ne "Running")
{
Write-Host "OMED Service was not started."
Write-Host "Start OMED service Manually."
} else {
Write-Host "OMED Service started successfully."
}
}else{
Write-Host "OMED Service is already Running."
}
</Script></ScriptBody>
<Parameters/>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
<StrictErrorHandling>true</StrictErrorHandling>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="EnableService"/>
</Composition>
</Composite>
</ModuleImplementation>
<InputType>System!System.BaseData</InputType>
</WriteActionModuleType>