Microsoft.KnowledgeServices.Windows.HyperV.ServerRole_Discovery

Microsoft.KnowledgeServices.Windows.HyperV.ServerRole_Discovery (Discovery)

Discovery module for class Microsoft.KnowledgeServices.Windows.HyperV.ServerRole

Element properties:

TargetMicrosoft.Windows.HyperV.ServerRole
EnabledTrue
Frequency44092
RemotableFalse

Object Discovery Details:

Discovered Classes and their attribuets:

Member Modules:

ID Module Type TypeId RunAs 
Microsoft.KnowledgeServices.Windows.HyperV.ServerRole_Discovery DataSource Microsoft.Windows.TimedPowerShell.DiscoveryProvider Default

Source Code:

<Discovery ID="Microsoft.KnowledgeServices.Windows.HyperV.ServerRole_Discovery" Enabled="true" Target="MicrosoftWindowsHyperVLibrary!Microsoft.Windows.HyperV.ServerRole" ConfirmDelivery="true" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="MicrosoftKnowledgeServicesWindowsHyperVLibrary!Microsoft.KnowledgeServices.Windows.HyperV.ServerRole">
<Property TypeID="MicrosoftKnowledgeServicesWindowsHyperVLibrary!Microsoft.KnowledgeServices.Windows.HyperV.ServerRole" PropertyID="OSVersionMajor"/>
<Property TypeID="MicrosoftKnowledgeServicesWindowsHyperVLibrary!Microsoft.KnowledgeServices.Windows.HyperV.ServerRole" PropertyID="OSVersionMinor"/>
<Property TypeID="MicrosoftKnowledgeServicesWindowsHyperVLibrary!Microsoft.KnowledgeServices.Windows.HyperV.ServerRole" PropertyID="OSVersionBuild"/>
<Property TypeID="MicrosoftKnowledgeServicesWindowsHyperVLibrary!Microsoft.KnowledgeServices.Windows.HyperV.ServerRole" PropertyID="OSSystem32Folder"/>
<Property TypeID="MicrosoftKnowledgeServicesWindowsHyperVLibrary!Microsoft.KnowledgeServices.Windows.HyperV.ServerRole" PropertyID="ManagementPackVersion"/>
</DiscoveryClass>
</DiscoveryTypes>
<DataSource ID="Microsoft.KnowledgeServices.Windows.HyperV.ServerRole_Discovery" TypeID="Windows!Microsoft.Windows.TimedPowerShell.DiscoveryProvider">
<IntervalSeconds>44092</IntervalSeconds>
<SyncTime/>
<ScriptName>ServerRoleExtension.ps1</ScriptName>
<ScriptBody><Script>

param($SourceId,$ManagedEntityId,$KeyPropertyServerId,$KeyPropertyPrincipalName)

$ErrorActionPreference = "Stop"

# Set up the arguments
$scriptargs = new-object psobject
$scriptargs | add-member NoteProperty "SourceId" $SourceId
$scriptargs | add-member NoteProperty "ManagedEntityId" $ManagedEntityId
$scriptargs | add-member NoteProperty "KeyPropertyServerId" $KeyPropertyServerId
$scriptargs | add-member NoteProperty "KeyPropertyPrincipalName" $KeyPropertyPrincipalName

# Set up the discovery output
$discoveryoutput = new-object psobject
$discoveryoutput | add-member NoteProperty "OSVersionMajor" ""
$discoveryoutput | add-member NoteProperty "OSVersionMinor" ""
$discoveryoutput | add-member NoteProperty "OSVersionBuild" ""
$discoveryoutput | add-member NoteProperty "OSSystem32Folder" ""
$discoveryoutput | add-member NoteProperty "ManagementPackVersion" ""

#-----------------------------------------------------
# Environment
#-----------------------------------------------------

$ScriptEnv = new-object psobject
$ScriptEnv | add-member ScriptMethod "GetWin32OSWMIClass" -value {
Get-WmiObject -Class Win32_OperatingSystem
}

$ScriptEnv | add-member ScriptMethod "GetOSEnvironmentVersion" -value {
[Environment]::OSVersion.Version
}


#-----------------------------------------------------
# Main Discovery Function
#-----------------------------------------------------
function AdvisorDiscovery($scriptargs, $discoveryoutput)
{
$Win32OSClass = $ScriptEnv.GetWin32OSWMIClass()
$OSVersion = $ScriptEnv.GetOSEnvironmentVersion()
$mpVersion = "1.0.48.0"

$discoveryoutput.OSVersionMajor = $OSVersion.Major
$discoveryoutput.OSVersionMinor = $OSVersion.Minor
$discoveryoutput.OSVersionBuild = $OSVersion.Build

$discoveryoutput.OSSystem32Folder = $Win32OSClass.SystemDirectory

$discoveryoutput.ManagementPackVersion = $mpVersion

}


# Create a new discovery data packet
$oAPI = new-object -comObject "MOM.ScriptAPI"

$discoverydata = $oAPI.CreateDiscoveryData(0, $scriptargs.SourceId, $scriptargs.ManagedEntityId)
$instance = $discoverydata.CreateClassInstance("$MPElement[Name='MicrosoftKnowledgeServicesWindowsHyperVLibrary!Microsoft.KnowledgeServices.Windows.HyperV.ServerRole']$")
$instance.AddProperty("$MPElement[Name='MicrosoftWindowsHyperVLibrary!Microsoft.Windows.HyperV.ServerRole']/ServerId$", $scriptargs.KeyPropertyServerId)
$instance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $scriptargs.KeyPropertyPrincipalName)

AdvisorDiscovery $scriptargs $discoveryoutput

# set the discovery output
$instance.AddProperty("$MPElement[Name='MicrosoftKnowledgeServicesWindowsHyperVLibrary!Microsoft.KnowledgeServices.Windows.HyperV.ServerRole']/OSVersionMajor$", $discoveryoutput.OSVersionMajor)
$instance.AddProperty("$MPElement[Name='MicrosoftKnowledgeServicesWindowsHyperVLibrary!Microsoft.KnowledgeServices.Windows.HyperV.ServerRole']/OSVersionMinor$", $discoveryoutput.OSVersionMinor)
$instance.AddProperty("$MPElement[Name='MicrosoftKnowledgeServicesWindowsHyperVLibrary!Microsoft.KnowledgeServices.Windows.HyperV.ServerRole']/OSVersionBuild$", $discoveryoutput.OSVersionBuild)
$instance.AddProperty("$MPElement[Name='MicrosoftKnowledgeServicesWindowsHyperVLibrary!Microsoft.KnowledgeServices.Windows.HyperV.ServerRole']/OSSystem32Folder$", $discoveryoutput.OSSystem32Folder)
$instance.AddProperty("$MPElement[Name='MicrosoftKnowledgeServicesWindowsHyperVLibrary!Microsoft.KnowledgeServices.Windows.HyperV.ServerRole']/ManagementPackVersion$", $discoveryoutput.ManagementPackVersion)

$discoverydata.AddInstance($instance)
$discoverydata

</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>SourceId</Name>
<Value>$MPElement$</Value>
</Parameter>
<Parameter>
<Name>ManagedEntityId</Name>
<Value>$Target/Id$</Value>
</Parameter>
<Parameter>
<Name>KeyPropertyServerId</Name>
<Value>$Target/Property[Type="MicrosoftWindowsHyperVLibrary!Microsoft.Windows.HyperV.ServerRole"]/ServerId$</Value>
</Parameter>
<Parameter>
<Name>KeyPropertyPrincipalName</Name>
<Value>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>300</TimeoutSeconds>
<StrictErrorHandling>false</StrictErrorHandling>
</DataSource>
</Discovery>