Windows Server AppFabric Local Service DS

Microsoft.ApplicationServer.LocalService.DS (DataSourceModuleType)

This is the data source used to collect discovery data via a command execution

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityPublic
RunAsDefault
OutputTypeSystem.Discovery.Data

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource System.CommandExecuterDiscoveryDataSource Default

Source Code:

<DataSourceModuleType ID="Microsoft.ApplicationServer.LocalService.DS" Accessibility="Public" Batching="false">
<Configuration>
<xsd:element minOccurs="1" name="TimeoutSeconds" type="xsd:integer"/>
<xsd:element minOccurs="1" name="IntervalSeconds" type="xsd:integer"/>
</Configuration>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<DataSource ID="DS" TypeID="System!System.CommandExecuterDiscoveryDataSource">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<ApplicationName>%windir%\system32\windowspowershell\v1.0\powershell.exe</ApplicationName>
<WorkingDirectory/>
<CommandLine>-Command ".\Create-LocalServices.ps1" </CommandLine>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
<RequireOutput>true</RequireOutput>
<Files>
<File>
<Name>Create-LocalServices.ps1</Name>
<Contents><Script>


$oAPI = new-object -comObject "MOM.ScriptAPI"
$Discovery = $oAPI.CreateDiscoveryData(0, '$MPElement$', '$Target/Id$')

#$oAPI.LogScriptEvent("Create-LocalServices.ps1", 123, 4, "Init")

[string]$EventCollectorServiceName = "EventCollectorService.exe"
[string]$WfManagementServiceName = "WorkflowManagementService.exe"
[string]$distributedCacheServiceName = "DistributedCacheService.exe"

$localServices = Get-WmiObject Win32_Service | Where { $_.PathName -match $EventCollectorServiceName -or $_.PathName -match $WfManagementServiceName -or $_.PathName -match $distributedCacheServiceName}

if($localServices -ne $null)
{
foreach($localService in $localServices)
{
[bool]$isEventCollectorService = $false
[bool]$isWfManagementService = $false
[bool]$isDistributedCacheService = $false
[int]$isServiceConfigured = 0
$discoveredService = $null

if ($localService.PathName.Contains($EventCollectorServiceName))
{
$isEventCollectorService = $true
$discoveredService = $Discovery.CreateClassInstance("$MPElement[Name='MicrosoftApplicationServerLibrary!Microsoft.ApplicationServer.EventCollectorService']$")
}
elseif ($localService.PathName.Contains($WfManagementServiceName))
{
$isWfManagementService = $true
$discoveredService = $Discovery.CreateClassInstance("$MPElement[Name='MicrosoftApplicationServerLibrary!Microsoft.ApplicationServer.WFManagementService']$")
}
elseif ($localService.PathName.Contains($distributedCacheServiceName))
{
$isDistributedCacheService = $true
$isServiceConfigured = (Get-ItemProperty HKLM:\SOFTWARE\Microsoft\AppFabric\v1.0\Configuration).ServiceConfigured
$discoveredService = $Discovery.CreateClassInstance("$MPElement[Name='MicrosoftApplicationServerLibrary!Microsoft.DistributedCache.CacheHostService']$")
}

$discoveredService.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", '$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$')
$discoveredService.AddProperty("$MPElement[Name='MicrosoftApplicationServerLibrary!Microsoft.ApplicationServer.LocalService']/ServiceName$", $localService.Name)
$discoveredService.AddProperty("$MPElement[Name='MicrosoftApplicationServerLibrary!Microsoft.ApplicationServer.LocalService']/Description$", $localService.Description)
$discoveredService.AddProperty("$MPElement[Name='MicrosoftApplicationServerLibrary!Microsoft.ApplicationServer.LocalService']/ImagePath$", $localService.PathName)
$discoveredService.AddProperty("$MPElement[Name='MicrosoftApplicationServerLibrary!Microsoft.ApplicationServer.LocalService']/StartMode$", $localService.StartMode)
$discoveredService.AddProperty("$MPElement[Name='MicrosoftApplicationServerLibrary!Microsoft.ApplicationServer.LocalService']/RunAs$", $localService.StartName)

$discoveredService.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $localService.DisplayName)

$name = [string]::Empty
if ($isEventCollectorService -and $localService.PathName.Contains(" -name "))
{
[Array]$splitChar = ' '
[string[]]$serviceArguments = $localService.PathName.Split($splitChar, 1)
for($index = 0; $index -lt $serviceArguments.Length; $index++)
{
if (($serviceArguments[$index].CompareTo("-name") -eq 0) -and (($index + 1) -lt $serviceArguments.Length))
{
$name = $serviceArguments[$index + 1]
break;
}
}
}
else
{
[int]$index = $localService.PathName.IndexOf($serviceExecutableName)
if (($index -ge 0) -and ($index + $serviceExecutableName.Length -lt $localService.PathName.Length))
{
$name = $localService.PathName.Substring($index + $serviceExecutableName.Length + 1);
$name = $name.Trim();
}
}

if ($isEventCollectorService)
{
$discoveredService.AddProperty("$MPElement[Name='MicrosoftApplicationServerLibrary!Microsoft.ApplicationServer.EventCollectorService']/CollectorName$", $name)
}
elseif ($isWfManagementService) # if WF Management Service
{
if ([string]::IsNullOrEmpty($name))
{
$name = 'Nameless_WMS_Instance'
}

$discoveredService.AddProperty("$MPElement[Name='MicrosoftApplicationServerLibrary!Microsoft.ApplicationServer.WFManagementService']/ManagementName$", $name)
}
elseif ($isDistributedCacheService -and (($isServiceConfigured -eq $null) -or ($isServiceConfigured -eq 0)))
{
continue
}

$Discovery.AddInstance($discoveredService)
}
}

# Return the discovery data by calling the variable
$oAPI.Return($Discovery)
return

trap
{
if ($oAPI -ne $null)
{
foreach($errorDetail in $Error)
{
$oAPI.LogScriptEvent("Create-LocalServices.ps1", 100, 1, $errorDetail.Exception)
}
}

return
}

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