Reinstall CIM Indications Listener service Probe Action
Fujitsu.Servers.PRIMERGY.ESXi.Seed.ReinstallCIMListenerService.Probe (ProbeActionModuleType)
Element properties:
Member Modules:
Overrideable Parameters:
Source Code:
<ProbeActionModuleType ID="Fujitsu.Servers.PRIMERGY.ESXi.Seed.ReinstallCIMListenerService.Probe" Accessibility="Public">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="HostServer" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ListenPort" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ListenProtocol" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TimeoutSeconds" type="xsd:int"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="HostServer" Selector="$Config/HostServer$" ParameterType="string"/>
<OverrideableParameter ID="ListenPort" Selector="$Config/ListenPort$" ParameterType="string"/>
<OverrideableParameter ID="ListenProtocol" Selector="$Config/ListenProtocol$" ParameterType="string"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<ProbeAction ID="PA" TypeID="Windows!Microsoft.Windows.PowerShellPropertyBagProbe">
<ScriptName>ReinstallCIMIndicationsListenerTask.ps1</ScriptName>
<ScriptBody><Script>
#-------------------------------------------------------------------
# Fujitsu
# Copyright 2015-2019 FUJITSU LIMITED
#
# ReinstallCIMIndicationsListenerTask.ps1
#
# Summary:
# Script reinstall CIM Indications Listener service.
#
#-------------------------------------------------------------------
param (
[string] $HostServer,
[string] $PrincipalName,
[string] $ListenPort = "",
[string] $ListenProtocol = "",
[switch] $OutsideManagementPack
)
Import-Module ("$FileResource[Name='Fujitsu.Servers.PRIMERGY.PS.CommonModule']/Path$", "$PSScriptRoot\Modules\CommonModule.psm1" )[[bool]$OutsideManagementPack]
Import-Module ("$FileResource[Name='Fujitsu.Servers.PRIMERGY.PS.LoggerModule']/Path$", "$PSScriptRoot\Modules\LoggerModule.psm1" )[[bool]$OutsideManagementPack]
Import-Module ("$FileResource[Name='Fujitsu.Servers.PRIMERGY.PS.CIMIndicationsListener']/Path$", "$PSScriptRoot\Modules\CIMIndicationsListener.psm1")[[bool]$OutsideManagementPack] -Force
$script:servicePath = ("$FileResource[Name='Fujitsu.Servers.PRIMERGY.CIMIndicationsListener']/Path$", "$PSScriptRoot\..\Resources\Fujitsu.Servers.PRIMERGY.CIMIndicationsListener.exe")[[bool]$OutsideManagementPack]
function Main {
$script:Logger = New-Logger -Section $SectionHostServer -HostTag $TagHostsDiscovery -ServerName $PrincipalName -ScriptName "ReinstallCIMIndicationsListenerTask.ps1" -OutsideManagementPack:$OutsideManagementPack
Set-CIMIndicationsListenerLogger $Logger
$Logger.Debug("HostServer = $HostServer")
$Logger.Debug("PrincipalName = $PrincipalName")
if ($HostServer -eq $PrincipalName) {
$Logger.Debug("ServicePath = $ServicePath")
$ver = Get-RegValue -SubKey $RegKeyCIMListener -Property $RegValueVersion
$port = Get-RegValue -SubKey $RegKeyCIMListener -Property $RegValueListenPort
$protocol = Get-RegValue -SubKey $RegKeyCIMListener -Property $RegValueListenProtocol
$status = Get-RegValue -SubKey $RegKeyCIMListener -Property $RegValueDeployStatus
$Logger.Debug("ServiceVersion = $ver")
$Logger.Debug("ServicePort = $port")
$Logger.Debug("ServiceProtocol = $protocol")
$Logger.Debug("ServiceStatus = $status")
try {
Reinstall-CIMListenerService
} catch {
$ErrorMessage = $_.Exception.Message
Out-PropertyBag "ERROR: $ErrorMessage"
Exit
}
Out-PropertyBag "SUCCESS"
}
$Logger.Debug("***** Normal end of script. *****")
}
function Reinstall-CIMListenerService {
Uninstall-CIMListenerService
Disable-CIMListenerCertificateForPort $port
if ($ListenPort -ne "") {
$port = $ListenPort
Set-ItemProperty -Path "$RootRegistryKey\$RegKeyCIMListener" -Name $RegValueListenPort -Type String -Value $port -Force
$Logger.Debug("NewServicePort = $port")
}
if ($ListenProtocol -ne "") {
$protocol = $ListenProtocol
Set-ItemProperty -Path "$RootRegistryKey\$RegKeyCIMListener" -Name $RegValueListenProtocol -Type String -Value $protocol -Force
$Logger.Debug("NewSrvProtocol = $protocol")
}
if ($protocol -ieq "https") {
$thumbprint = New-CIMListenerCertificate
Enable-CIMListenerCertificateForPort -Thumbprint $thumbprint -Port ([int]$port)
}
$logName = Get-RegValue -SubKey $RegKeyCIMListener -Property $RegValueEventLogName
$logSource = Get-RegValue -SubKey $RegKeyCIMListener -Property $RegValueEventLogSource
Install-CIMListenerService -ServicePath $servicePath -LogName $logName -LogSource $logSource
}
function Out-PropertyBag {
param ( [string] $Result )
$oAPI = New-SCOMApiObject -OutsideManagementPack:$OutsideManagementPack
$propertyBagData = $oAPI.CreatePropertyBag()
$propertyBagData.AddValue("Result", $Result)
$propertyBagData
$Logger.Debug("TaskResult = $Result")
}
try {
Main
} finally {
$Logger.OutputBuffer()
}
</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>HostServer</Name>
<Value>$Config/HostServer$</Value>
</Parameter>
<Parameter>
<Name>PrincipalName</Name>
<Value>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$</Value>
</Parameter>
<Parameter>
<Name>ListenPort</Name>
<Value>$Config/ListenPort$</Value>
</Parameter>
<Parameter>
<Name>ListenProtocol</Name>
<Value>$Config/ListenProtocol$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="PA"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
<InputType>System!System.BaseData</InputType>
</ProbeActionModuleType>