<DataSourceModuleType ID="LW.Microsoft.Windows.NonServerRoles.Registry.Discovery.DataSource" Accessibility="Public" RunAs="System!System.PrivilegedMonitoringAccount" Batching="false">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="IntervalSeconds" type="xsd:unsignedInt"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="ComputerPrincipalName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="TimeoutSeconds" type="xsd:unsignedInt"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<DataSource ID="Scheduler" TypeID="System!System.Discovery.Scheduler">
<Scheduler>
<SimpleReccuringSchedule>
<Interval Unit="Seconds">$Config/IntervalSeconds$</Interval>
</SimpleReccuringSchedule>
<ExcludeDates/>
</Scheduler>
</DataSource>
<ProbeAction ID="PowerShellDiscoveryProbe" TypeID="Windows!Microsoft.Windows.PowerShellDiscoveryProbe">
<ScriptName>"Lightweight non server roles discovery script"</ScriptName>
<ScriptBody><Script>
param ([String] $sourceID, [String] $managedEntityID, [String] $computerName)
#Copyright (c) Microsoft Corporation. All rights reserved.
#*************************************************************************
#Author - Arpit Mittal
#ScriptName: "NonServerRoles.ps1"$
#Purpose: This script will discover installed non-server roles on the Windows computers
#by searching the registries
#*************************************************************************
#Table containing class name with multiple registry paths
$registryPathTable = @{}
#Table containing key value pairs for each registry path
$regKeyValuePairs = @{}
#Mapping of class names with their class instance names
$classMPElementTable = @{}
#Mapping of class name with category names
$classCategoryTable = @{}
#Get-WindowsFeature Discoveries
#SQL Server 2005
$registryPathTable.Add("LW.Microsoft.Windows.SQL.Server.2005",@("HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\90\Machines"))
$classMPElementTable.Add("LW.Microsoft.Windows.SQL.Server.2005","`$MPElement[Name='LW.Microsoft.Windows.SQL.Server.2005']$")
$classCategoryTable.Add("LW.Microsoft.Windows.SQL.Server.2005","SQL Server 2005")
#SQL Server 2008
$registryPathTable.Add("LW.Microsoft.Windows.SQL.Server.2008",@("HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\100\Machines"))
$classMPElementTable.Add("LW.Microsoft.Windows.SQL.Server.2008","`$MPElement[Name='LW.Microsoft.Windows.SQL.Server.2008']$")
$classCategoryTable.Add("LW.Microsoft.Windows.SQL.Server.2008","SQL Server 2008")
#SQL Server 2012
$registryPathTable.Add("LW.Microsoft.Windows.SQL.Server.2012",@("HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\110\Machines"))
$classMPElementTable.Add("LW.Microsoft.Windows.SQL.Server.2012","`$MPElement[Name='LW.Microsoft.Windows.SQL.Server.2012']$")
$classCategoryTable.Add("LW.Microsoft.Windows.SQL.Server.2012","SQL Server 2012")
#SQL Server 2014
$registryPathTable.Add("LW.Microsoft.Windows.SQL.Server.2014",@("HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\120\Machines"))
$classMPElementTable.Add("LW.Microsoft.Windows.SQL.Server.2014","`$MPElement[Name='LW.Microsoft.Windows.SQL.Server.2014']$")
$classCategoryTable.Add("LW.Microsoft.Windows.SQL.Server.2014","SQL Server 2014")
#Windows Server Backup
$registryPathTable.Add("LW.Microsoft.Windows.Server.Backup",("HKLM:\SYSTEM\CurrentControlSet\Services\wbengine"))
$regKeyValuePairs.Add("HKLM:\SYSTEM\CurrentControlSet\Services\wbengine\LW.Microsoft.Windows.Server.Backup",@{"ImagePath"="%systemroot%\system32\wbengine.exe"})
$classMPElementTable.Add("LW.Microsoft.Windows.Server.Backup","`$MPElement[Name='LW.Microsoft.Windows.Server.Backup']$")
$classCategoryTable.Add("LW.Microsoft.Windows.Server.Backup","Windows Server Backup")
#BizTalk server 2013
$registryPathTable.Add("LW.Microsoft.Windows.Biztalk.2013",("HKLM:\SOFTWARE\Microsoft\BizTalk Server\3.0"))
$regKeyValuePairs.Add("HKLM:\SOFTWARE\Microsoft\BizTalk Server\3.0\LW.Microsoft.Windows.Biztalk.2013",@{"ProductVersion"="3.10.229.0"})
$classMPElementTable.Add("LW.Microsoft.Windows.Biztalk.2013","`$MPElement[Name='LW.Microsoft.Windows.Biztalk.2013']$")
$classCategoryTable.Add("LW.Microsoft.Windows.Biztalk.2013","BizTalk 2013")
#NAV 2013
$registryPathTable.Add("LW.Microsoft.Windows.NAV.2013",("HKLM:\SOFTWARE\Microsoft\Microsoft Dynamics NAV\70\Service"))
$classMPElementTable.Add("LW.Microsoft.Windows.NAV.2013","`$MPElement[Name='LW.Microsoft.Windows.NAV.2013']$")
$classCategoryTable.Add("LW.Microsoft.Windows.NAV.2013","Dynamics NAV 2013")
#NAV 2013R2
$registryPathTable.Add("LW.Microsoft.Windows.NAV.2013R2",("HKLM:\SOFTWARE\Microsoft\Microsoft Dynamics NAV\71\Service"))
$classMPElementTable.Add("LW.Microsoft.Windows.NAV.2013R2","`$MPElement[Name='LW.Microsoft.Windows.NAV.2013R2']$")
$classCategoryTable.Add("LW.Microsoft.Windows.NAV.2013R2","Dynamics NAV 2013")
#Exchange Server 2013
$registryPathTable.Add("LW.Microsoft.Windows.Exchange.Server.2013",("HKLM:\SOFTWARE\Microsoft\ExchangeServer\v15\Setup"))
$classMPElementTable.Add("LW.Microsoft.Windows.Exchange.Server.2013","`$MPElement[Name='LW.Microsoft.Windows.Exchange.Server.2013']$")
$classCategoryTable.Add("LW.Microsoft.Windows.Exchange.Server.2013","Exchange 2013")
#SharePoint Server 2013
$registryPathTable.Add("LW.Microsoft.Windows.SharePoint.Server.2013",("HKLM:\SOFTWARE\Microsoft\Office Server\15.0"))
$classMPElementTable.Add("LW.Microsoft.Windows.SharePoint.Server.2013","`$MPElement[Name='LW.Microsoft.Windows.SharePoint.Server.2013']$")
$classCategoryTable.Add("LW.Microsoft.Windows.SharePoint.Server.2013","SharePoint Server 2013")
#SharePoint Foundation Server 2013
$registryPathTable.Add("LW.Microsoft.Windows.SharePoint.Foundation.Server.2013",("HKLM:\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\15.0\WSS"))
$classMPElementTable.Add("LW.Microsoft.Windows.SharePoint.Foundation.Server.2013","`$MPElement[Name='LW.Microsoft.Windows.SharePoint.Foundation.Server.2013']$")
$classCategoryTable.Add("LW.Microsoft.Windows.SharePoint.Foundation.Server.2013","SharePoint Foundation 2013")
#Service Manager 2012 (RTM, SP1, R2)
$registryPathTable.Add("LW.Microsoft.Windows.ServiceManager.2012",@("HKLM:\SOFTWARE\Microsoft\System Center\2010\Service Manager\Setup"))
$regKeyValuePairs.Add("HKLM:\SOFTWARE\Microsoft\System Center\2010\Service Manager\Setup\LW.Microsoft.Windows.ServiceManager.2012",@{"CurrentVersion"="^7.5*"})
$classMPElementTable.Add("LW.Microsoft.Windows.ServiceManager.2012","`$MPElement[Name='LW.Microsoft.Windows.ServiceManager.2012']$")
$classCategoryTable.Add("LW.Microsoft.Windows.ServiceManager.2012","System Center 2012 - Service Manager")
#TFS 2010
$registryPathTable.Add("LW.Microsoft.Windows.TFS.2010",@("HKLM:\SOFTWARE\Microsoft\TeamFoundationServer\10.0\InstalledComponents\ApplicationTier"))
$regKeyValuePairs.Add("HKLM:\SOFTWARE\Microsoft\TeamFoundationServer\10.0\InstalledComponents\ApplicationTier\LW.Microsoft.Windows.TFS.2010",@{"IsConfigured"="^1"})
$classMPElementTable.Add("LW.Microsoft.Windows.TFS.2010","`$MPElement[Name='LW.Microsoft.Windows.TFS.2010']$")
$classCategoryTable.Add("LW.Microsoft.Windows.TFS.2010","Team Foundation Server 2010")
#TFS 2012
$registryPathTable.Add("LW.Microsoft.Windows.TFS.2012",@("HKLM:\SOFTWARE\Microsoft\TeamFoundationServer\11.0\InstalledComponents\ApplicationTier"))
$regKeyValuePairs.Add("HKLM:\SOFTWARE\Microsoft\TeamFoundationServer\11.0\InstalledComponents\ApplicationTier\LW.Microsoft.Windows.TFS.2012",@{"IsConfigured"="^1"})
$classMPElementTable.Add("LW.Microsoft.Windows.TFS.2012","`$MPElement[Name='LW.Microsoft.Windows.TFS.2012']$")
$classCategoryTable.Add("LW.Microsoft.Windows.TFS.2012","Team Foundation Server 2012")
#TFS 2013
$registryPathTable.Add("LW.Microsoft.Windows.TFS.2013",@("HKLM:\SOFTWARE\Microsoft\TeamFoundationServer\12.0\InstalledComponents\ApplicationTier"))
$regKeyValuePairs.Add("HKLM:\SOFTWARE\Microsoft\TeamFoundationServer\12.0\InstalledComponents\ApplicationTier\LW.Microsoft.Windows.TFS.2013",@{"IsConfigured"="^1"})
$classMPElementTable.Add("LW.Microsoft.Windows.TFS.2013","`$MPElement[Name='LW.Microsoft.Windows.TFS.2013']$")
$classCategoryTable.Add("LW.Microsoft.Windows.TFS.2013","Team Foundation Server 2013")
#TFS 2015
$registryPathTable.Add("LW.Microsoft.Windows.TFS.2015",@("HKLM:\SOFTWARE\Microsoft\TeamFoundationServer\14.0\InstalledComponents\ApplicationTier"))
$regKeyValuePairs.Add("HKLM:\SOFTWARE\Microsoft\TeamFoundationServer\14.0\InstalledComponents\ApplicationTier\LW.Microsoft.Windows.TFS.2015",@{"IsConfigured"="^1"})
$classMPElementTable.Add("LW.Microsoft.Windows.TFS.2015","`$MPElement[Name='LW.Microsoft.Windows.TFS.2015']$")
$classCategoryTable.Add("LW.Microsoft.Windows.TFS.2015","Team Foundation Server 2015")
#SQL Server 2016
$registryPathTable.Add("LW.Microsoft.Windows.SQL.Server.2016",@("HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\130\Machines"))
$classMPElementTable.Add("LW.Microsoft.Windows.SQL.Server.2016","`$MPElement[Name='LW.Microsoft.Windows.SQL.Server.2016']$")
$classCategoryTable.Add("LW.Microsoft.Windows.SQL.Server.2016","SQL Server 2016")
#Host Integration Server 2010
$registryPathTable.Add("LW.Microsoft.Windows.Host.Integration.Server.2010",("HKLM:\SOFTWARE\Microsoft\SNA Server\CurrentVersion"))
$regKeyValuePairs.Add("HKLM:\SOFTWARE\Microsoft\SNA Server\CurrentVersion\LW.Microsoft.Windows.Host.Integration.Server.2010",@{"SNAVersion"="^8.5*"})
$classMPElementTable.Add("LW.Microsoft.Windows.Host.Integration.Server.2010","`$MPElement[Name='LW.Microsoft.Windows.Host.Integration.Server.2010']$")
$classCategoryTable.Add("LW.Microsoft.Windows.Host.Integration.Server.2010","Host Integration Server 2010")
#SharePoint Foundation Server 2010
$registryPathTable.Add("LW.Microsoft.Windows.SharePoint.Foundation.Server.2010",("HKLM:\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\WSS"))
$classMPElementTable.Add("LW.Microsoft.Windows.SharePoint.Foundation.Server.2010","`$MPElement[Name='LW.Microsoft.Windows.SharePoint.Foundation.Server.2010']$")
$classCategoryTable.Add("LW.Microsoft.Windows.SharePoint.Foundation.Server.2010","Office SharePoint Foundation 2010")
#BizTalk server 2010
$registryPathTable.Add("LW.Microsoft.Windows.Biztalk.2010",("HKLM:\SOFTWARE\Microsoft\BizTalk Server\3.0"))
$regKeyValuePairs.Add("HKLM:\SOFTWARE\Microsoft\BizTalk Server\3.0\LW.Microsoft.Windows.Biztalk.2010",@{"ProductVersion"="3.9.469.0"})
$classMPElementTable.Add("LW.Microsoft.Windows.Biztalk.2010","`$MPElement[Name='LW.Microsoft.Windows.Biztalk.2010']$")
$classCategoryTable.Add("LW.Microsoft.Windows.Biztalk.2010","BizTalk 2010")
#BizTalk server 2009
$registryPathTable.Add("LW.Microsoft.Windows.Biztalk.2009",("HKLM:\SOFTWARE\Microsoft\BizTalk Server\3.0"))
$regKeyValuePairs.Add("HKLM:\SOFTWARE\Microsoft\BizTalk Server\3.0\LW.Microsoft.Windows.Biztalk.2009",@{"ProductVersion"="3.8.368.0"})
$classMPElementTable.Add("LW.Microsoft.Windows.Biztalk.2009","`$MPElement[Name='LW.Microsoft.Windows.Biztalk.2009']$")
$classCategoryTable.Add("LW.Microsoft.Windows.Biztalk.2009","BizTalk 2009")
#BizTalk server 2006
$registryPathTable.Add("LW.Microsoft.Windows.Biztalk.2006",("HKLM:\SOFTWARE\Microsoft\BizTalk Server\3.0"))
$regKeyValuePairs.Add("HKLM:\SOFTWARE\Microsoft\BizTalk Server\3.0\LW.Microsoft.Windows.Biztalk.2006",@{"ProductVersion"="3.5.1602.0"})
$classMPElementTable.Add("LW.Microsoft.Windows.Biztalk.2006","`$MPElement[Name='LW.Microsoft.Windows.Biztalk.2006']$")
$classCategoryTable.Add("LW.Microsoft.Windows.Biztalk.2006","BizTalk 2006")
#SQL Server 2016 Reporting Services (Native Mode)
$registryPathTable.Add("LW.Microsoft.Windows.SQL.Server.2016.ReportingServices.NativeMode",("HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\130\Machines"))
$classMPElementTable.Add("LW.Microsoft.Windows.SQL.Server.2016.ReportingServices.NativeMode","`$MPElement[Name='LW.Microsoft.Windows.SQL.Server.2016.ReportingServices.NativeMode']$")
$classCategoryTable.Add("LW.Microsoft.Windows.SQL.Server.2016.ReportingServices.NativeMode","SQL Server 2016 Reporting Services (Native Mode)")
#SQL Server 2014 Reporting Services (Native Mode)
$registryPathTable.Add("LW.Microsoft.Windows.SQL.Server.2014.ReportingServices.NativeMode",("HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\120\Machines"))
$classMPElementTable.Add("LW.Microsoft.Windows.SQL.Server.2014.ReportingServices.NativeMode","`$MPElement[Name='LW.Microsoft.Windows.SQL.Server.2014.ReportingServices.NativeMode']$")
$classCategoryTable.Add("LW.Microsoft.Windows.SQL.Server.2014.ReportingServices.NativeMode","SQL Server 2014 Reporting Services (Native Mode)")
#SQL Server 2012 Reporting Services (Native Mode)
$registryPathTable.Add("LW.Microsoft.Windows.SQL.Server.2012.ReportingServices.NativeMode",("HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\110\Machines"))
$classMPElementTable.Add("LW.Microsoft.Windows.SQL.Server.2012.ReportingServices.NativeMode","`$MPElement[Name='LW.Microsoft.Windows.SQL.Server.2012.ReportingServices.NativeMode']$")
$classCategoryTable.Add("LW.Microsoft.Windows.SQL.Server.2012.ReportingServices.NativeMode","SQL Server 2012 Reporting Services (Native Mode)")
#SQL Server 2016 Analysis Services
$registryPathTable.Add("LW.Microsoft.Windows.SQL.Server.2016.AnalysisServices",("HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\130\Machines"))
$classMPElementTable.Add("LW.Microsoft.Windows.SQL.Server.2016.AnalysisServices","`$MPElement[Name='LW.Microsoft.Windows.SQL.Server.2016.AnalysisServices']$")
$classCategoryTable.Add("LW.Microsoft.Windows.SQL.Server.2016.AnalysisServices","SQL Server 2016 Analysis Services")
#SQL Server 2014 Analysis Services
$registryPathTable.Add("LW.Microsoft.Windows.SQL.Server.2014.AnalysisServices",("HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\120\Machines"))
$classMPElementTable.Add("LW.Microsoft.Windows.SQL.Server.2014.AnalysisServices","`$MPElement[Name='LW.Microsoft.Windows.SQL.Server.2014.AnalysisServices']$")
$classCategoryTable.Add("LW.Microsoft.Windows.SQL.Server.2014.AnalysisServices","SQL Server 2014 Analysis Services")
#SQL Server 2012 Analysis Services
$registryPathTable.Add("LW.Microsoft.Windows.SQL.Server.2012.AnalysisServices",("HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\110\Machines"))
$classMPElementTable.Add("LW.Microsoft.Windows.SQL.Server.2012.AnalysisServices","`$MPElement[Name='LW.Microsoft.Windows.SQL.Server.2012.AnalysisServices']$")
$classCategoryTable.Add("LW.Microsoft.Windows.SQL.Server.2012.AnalysisServices","SQL Server 2012 Analysis Services")
#SQL Server 2016 Replication
$registryPathTable.Add("LW.Microsoft.Windows.SQL.Server.2016.Replication",("HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\130\Machines"))
$classMPElementTable.Add("LW.Microsoft.Windows.SQL.Server.2016.Replication","`$MPElement[Name='LW.Microsoft.Windows.SQL.Server.2016.Replication']$")
$classCategoryTable.Add("LW.Microsoft.Windows.SQL.Server.2016.Replication","SQL Server 2016 Replication")
#SQL Server 2014 Replication
$registryPathTable.Add("LW.Microsoft.Windows.SQL.Server.2014.Replication",("HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\120\Machines"))
$classMPElementTable.Add("LW.Microsoft.Windows.SQL.Server.2014.Replication","`$MPElement[Name='LW.Microsoft.Windows.SQL.Server.2014.Replication']$")
$classCategoryTable.Add("LW.Microsoft.Windows.SQL.Server.2014.Replication","SQL Server 2014 Replication")
#SQL Server 2012 Replication
$registryPathTable.Add("LW.Microsoft.Windows.SQL.Server.2012.Replication",("HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\110\Machines"))
$classMPElementTable.Add("LW.Microsoft.Windows.SQL.Server.2012.Replication","`$MPElement[Name='LW.Microsoft.Windows.SQL.Server.2012.Replication']$")
$classCategoryTable.Add("LW.Microsoft.Windows.SQL.Server.2012.Replication","SQL Server 2012 Replication")
#SQL Server 2017+ Replication
$registryPathTable.Add("LW.Microsoft.Windows.SQL.Server.2017.Replication",("HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\140\Machines"))
$classMPElementTable.Add("LW.Microsoft.Windows.SQL.Server.2017.Replication","`$MPElement[Name='LW.Microsoft.Windows.SQL.Server.2017.Replication']$")
$classCategoryTable.Add("LW.Microsoft.Windows.SQL.Server.2017.Replication","SQL Server 2017+ Replication")
#SQL Server 2017+
$registryPathTable.Add("LW.Microsoft.Windows.SQL.Server.2017",@("HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\140\Machines"))
$classMPElementTable.Add("LW.Microsoft.Windows.SQL.Server.2017","`$MPElement[Name='LW.Microsoft.Windows.SQL.Server.2017']$")
$classCategoryTable.Add("LW.Microsoft.Windows.SQL.Server.2017","SQL Server 2017+")
#App Controler 2012
$registryPathTable.Add("LW.Microsoft.Windows.AppController.2012R2",@("HKLM:\SOFTWARE\Microsoft\Microsoft System Center App Controller"))
$classMPElementTable.Add("LW.Microsoft.Windows.AppController.2012R2","`$MPElement[Name='LW.Microsoft.Windows.AppController.2012R2']$")
$classCategoryTable.Add("LW.Microsoft.Windows.AppController.2012R2","System Center 2012 - App Controller")
#Lync.Server.2013
$registryPathTable.Add("LW.Microsoft.Lync.Server.2013",("HKLM:\Software\Microsoft\Real-Time Communications\{2A0B4BB2-4921-4b40-BA9E-81747CB84635}"))
$regKeyValuePairs.Add("HKLM:\Software\Microsoft\Real-Time Communications\{2A0B4BB2-4921-4b40-BA9E-81747CB84635}\LW.Microsoft.Lync.Server.2013",@{"Version"="^5"})
$classMPElementTable.Add("LW.Microsoft.Lync.Server.2013","`$MPElement[Name='LW.Microsoft.Lync.Server.2013']$")
$classCategoryTable.Add("LW.Microsoft.Lync.Server.2013","Lync Server 2013")
#LW.Microsoft.SkypeForBusiness.2015
$registryPathTable.Add("LW.Microsoft.SkypeForBusiness.2015",("HKLM:\Software\Microsoft\Real-Time Communications\{2A0B4BB2-4921-4b40-BA9E-81747CB84635}"))
$regKeyValuePairs.Add("HKLM:\Software\Microsoft\Real-Time Communications\{2A0B4BB2-4921-4b40-BA9E-81747CB84635}\LW.Microsoft.SkypeForBusiness.2015",@{"Version"="^6"})
$classMPElementTable.Add("LW.Microsoft.SkypeForBusiness.2015","`$MPElement[Name='LW.Microsoft.SkypeForBusiness.2015']$")
$classCategoryTable.Add("LW.Microsoft.SkypeForBusiness.2015","Skype for Business Server 2015")
#LW.Microsoft.3rdParty.Savision.SkypeForBusiness.2015
$registryPathTable.Add("LW.Microsoft.3rdParty.Savision.SkypeForBusiness.2015",("HKLM:\Software\Microsoft\Real-Time Communications\{2A0B4BB2-4921-4b40-BA9E-81747CB84635}"))
$regKeyValuePairs.Add("HKLM:\Software\Microsoft\Real-Time Communications\{2A0B4BB2-4921-4b40-BA9E-81747CB84635}\LW.Microsoft.3rdParty.Savision.SkypeForBusiness.2015",@{"Version"="^6"})
$classMPElementTable.Add("LW.Microsoft.3rdParty.Savision.SkypeForBusiness.2015","`$MPElement[Name='LW.Microsoft.3rdParty.Savision.SkypeForBusiness.2015']$")
$classCategoryTable.Add("LW.Microsoft.3rdParty.Savision.SkypeForBusiness.2015","Skype for Business Server 2015 (by Savision)")
function LogWrite
{
Param([string]$logString)
$script:logMessage += $logString
}
function Test-AllRegistryValue ($RegKeys)
{
$checkKeyExists = $true
foreach ($RegKey in $RegKeys)
{
$result = Test-RegistryValue $RegKey
if ( $result -eq $false )
{
$checkKeyExists = $false
}
}
return $checkKeyExists
}
function Test-AnyRegistryValue ($RegKeys)
{
$checkKeyExists = $false
ForEach ($RegKey in $RegKeys)
{
$result = Test-RegistryValue $RegKey
if ( $result -eq $true )
{
$checkKeyExists = $true
break
}
}
return $checkKeyExists
}
Function Check-Websphere($requiredVersion)
{
$usersList=Get-ChildItem Registry::HKEY_USERS|Select Name
foreach($user in $usersList)
{
$key1="Registry::"+$user.Name+"\Software\IBM\WebSphere Application Server";
$key2="Registry::"+$user.Name+"\Software\IBM\WebSphere Application Server Network Deployment";
Function Check-Weblogic($requiredVersion)
{
$query="Select CommandLine from Win32_Process WHERE Name LIKE 'java%.exe'"
$objects=Get-WmiObject -Query $query
$requiredObjects=$objects|Where-Object{$_.CommandLine -like '*-Dweblogic.home*'}
foreach($object in $requiredObjects)
{
$lines=$object.CommandLine.Split(" ");
foreach($line in $lines)
{
if($line -like '*-Dweblogic.home*')
{
$location=$line.replace("-Dweblogic.home=","");
break;
}
}
#This function will check the existence of registry path
#Providing path is mandatory, key value is optional
function Test-RegistryValue {
param (
[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]$Path,
[parameter(Mandatory=$false)]
[ValidateNotNullOrEmpty()]$Key,
[parameter(Mandatory=$false)]
[ValidateNotNullOrEmpty()]$Value
)
$checkRegistryKeyExists = $false
#Check if path exists
$isPathPresent = Test-Path $Path
#If only path argument was passed in function and path is present, then return true
if($isPathPresent -and ($Key -eq $null) -and ($Value -eq $null))
{
$checkRegistryKeyExists = $true
}
#handle other scenarios where key or value or both were passed in function arguments
elseif($isPathPresent)
{
#retrieve all keys present on that path
$allKeys = Get-ItemProperty $Path
#check if key parameter passed to the function is present in the retrieved keys list
if($allKeys.($Key))
{
#check if value is not null then match it with key or if value is null then return true
if((($Value -ne $null) -and $allKeys.($Key) -match $Value) -or ($Value -eq $null))
{
$checkRegistryKeyExists = $true
}
}
}
return $checkRegistryKeyExists
}
#scriptStartTime will help in calculating script run time
$scriptStartTime = Get-Date
$script:logMessage = ''
$GuestOS = ''
$wmiOS = (Get-WmiObject -Class Win32_OperatingSystem).caption
if (-not ([string]::IsNullOrEmpty($wmiOS)))
{
$GuestOS = $wmiOS
}
if(($SourceId -eq $null) -or ($ManagedEntityId -eq $null) -or ($computerName -eq $null))
{
LogWrite "`nNonServerRoles::SourceId, ManagedEntityId or Computer name is null. Exiting script."
Exit -1
}
#Create discovery property bag only once as we can't return multiple property bags
$api = new-object -comObject 'MOM.ScriptAPI'
$discoveryData = $api.CreateDiscoveryData(0, $SourceId, $ManagedEntityId)
#Iterate through discovery method table
if($registryPathTable -eq $null)
{
#Code shouldn't come here
LogWrite "`nNonServerRoles::Registry path table is empty. Exiting the script."
Exit -1
}
#Iterate through non-server roles list with their registry paths
foreach ($classDetails in $registryPathTable.GetEnumerator())
{
$className = $classDetails.Name
$regPaths = $classDetails.Value
#Let's set the bool to true for each non-server roles in the list and set to false if non-server role is not installed
$IsValidProperties = $true
#Only proceed if non-server role has some paths to test else continue to second entry in registryPathTable
if($regPaths.length -ne 0)
{
foreach($path in $regPaths)
{
$pathWithClass = "$path\$className"
#Check if we need to validate key value pairs for the given path else just test the existence of path
if($regKeyValuePairs.Item($pathWithClass) -ne $null)
{
$pairs = $regKeyValuePairs.Item($pathWithClass)
#As a precaution check - if somebody creates a false entry of path in the table with empty key value pairs
if($pairs.Count -ne 0)
{
foreach($keypair in $pairs.GetEnumerator())
{
#Test the path with key values
$valid = Test-RegistryValue -Path $path -Key $keyPair.Key -Value $keyPair.Value
if($valid -eq $false)
{
#Set the bool to false so that we don't create instance for this role
$IsValidProperties = $false
break
}
}
}
else
{
$IsValidProperties = $false
break
}
}
else
{
#Test the existence of the path which has no key value pairs and set bool to false if not found
$valid = Test-RegistryValue -Path $path
$scriptEndTime = Get-Date
$totalScriptRunTime = ($scriptEndTime - $scriptStartTime) | select-object TotalSeconds
$totalScriptRunTime = $totalScriptRunTime.TotalSeconds
LogWrite "`n Total time taken to run the script $totalScriptRunTime"
#Log an event after running the script
$api.LogScriptEvent("NonServerRoles.ps1", 5002, 0, $script:logMessage)