Microsoft Windows Server DNS Zone Discovery (DEPRECATED)

Microsoft.Windows.DNSServer.2016.Zone.Discovery (Discovery)

Discovers zones on the local DNS server (DEPRECATED)

Knowledge Base article:

Summary

Uses WMI to discover DNS zones.

Element properties:

TargetMicrosoft.Windows.DNSServer.2016.Server
EnabledTrue
Frequency14640
RemotableFalse

Object Discovery Details:

Discovered Classes and their attribuets:
  • Microsoft.Windows.DNSServer.2016.Zone
    • ZoneName
    • ZoneType
    • IsReverseZone
    • IsADIntegrated
    • AllowDynamicUpdates
    • AllowZoneTransfers
    • PrimaryServerName
    • ZoneFileName
    • UseWINS
    • HostName
    • NameServers
    • MasterServers
    • DisplayName
  • Microsoft.Windows.DNSServer.2016.Zone.Global
    • IsActivated
    • ZoneName
    • ZoneType
    • IsReverseZone
    • IsADIntegrated
    • AllowDynamicUpdates
    • AllowZoneTransfers
    • PrimaryServerName
    • ZoneFileName
    • UseWINS
    • HostName
    • NameServers
    • MasterServers
    • DisplayName
    • QueryOrder

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource Microsoft.Windows.TimedPowerShell.DiscoveryProvider Microsoft.Windows.DNSServer.2016.ActionAccount

Source Code:

<Discovery ID="Microsoft.Windows.DNSServer.2016.Zone.Discovery" Enabled="true" Target="Microsoft.Windows.DNSServer.2016.Server" ConfirmDelivery="false" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="Microsoft.Windows.DNSServer.2016.Zone">
<Property TypeID="Microsoft.Windows.DNSServer.2016.Zone" PropertyID="ZoneName"/>
<Property TypeID="Microsoft.Windows.DNSServer.2016.Zone" PropertyID="ZoneType"/>
<Property TypeID="Microsoft.Windows.DNSServer.2016.Zone" PropertyID="IsReverseZone"/>
<Property TypeID="Microsoft.Windows.DNSServer.2016.Zone" PropertyID="IsADIntegrated"/>
<Property TypeID="Microsoft.Windows.DNSServer.2016.Zone" PropertyID="AllowDynamicUpdates"/>
<Property TypeID="Microsoft.Windows.DNSServer.2016.Zone" PropertyID="AllowZoneTransfers"/>
<Property TypeID="Microsoft.Windows.DNSServer.2016.Zone" PropertyID="PrimaryServerName"/>
<Property TypeID="Microsoft.Windows.DNSServer.2016.Zone" PropertyID="ZoneFileName"/>
<Property TypeID="Microsoft.Windows.DNSServer.2016.Zone" PropertyID="UseWINS"/>
<Property TypeID="Microsoft.Windows.DNSServer.2016.Zone" PropertyID="HostName"/>
<Property TypeID="Microsoft.Windows.DNSServer.2016.Zone" PropertyID="NameServers"/>
<Property TypeID="Microsoft.Windows.DNSServer.2016.Zone" PropertyID="MasterServers"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Microsoft.Windows.DNSServer.2016.Zone.Global">
<Property TypeID="Microsoft.Windows.DNSServer.2016.Zone.Global" PropertyID="IsActivated"/>
<Property TypeID="Microsoft.Windows.DNSServer.2016.Zone" PropertyID="ZoneName"/>
<Property TypeID="Microsoft.Windows.DNSServer.2016.Zone" PropertyID="ZoneType"/>
<Property TypeID="Microsoft.Windows.DNSServer.2016.Zone" PropertyID="IsReverseZone"/>
<Property TypeID="Microsoft.Windows.DNSServer.2016.Zone" PropertyID="IsADIntegrated"/>
<Property TypeID="Microsoft.Windows.DNSServer.2016.Zone" PropertyID="AllowDynamicUpdates"/>
<Property TypeID="Microsoft.Windows.DNSServer.2016.Zone" PropertyID="AllowZoneTransfers"/>
<Property TypeID="Microsoft.Windows.DNSServer.2016.Zone" PropertyID="PrimaryServerName"/>
<Property TypeID="Microsoft.Windows.DNSServer.2016.Zone" PropertyID="ZoneFileName"/>
<Property TypeID="Microsoft.Windows.DNSServer.2016.Zone" PropertyID="UseWINS"/>
<Property TypeID="Microsoft.Windows.DNSServer.2016.Zone" PropertyID="HostName"/>
<Property TypeID="Microsoft.Windows.DNSServer.2016.Zone" PropertyID="NameServers"/>
<Property TypeID="Microsoft.Windows.DNSServer.2016.Zone" PropertyID="MasterServers"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
<Property TypeID="Microsoft.Windows.DNSServer.2016.Zone.Global" PropertyID="QueryOrder"/>
</DiscoveryClass>
</DiscoveryTypes>
<DataSource ID="DS" RunAs="Microsoft.Windows.DNSServer.2016.ActionAccount" TypeID="Windows!Microsoft.Windows.TimedPowerShell.DiscoveryProvider">
<IntervalSeconds>14640</IntervalSeconds>
<SyncTime/>
<ScriptName>Microsoft.Windows.Server.DNS.Zone.Discovery.ps1</ScriptName>
<ScriptBody><Script>#Copyright (c) Microsoft Corporation. All rights reserved.

#*************************************************************************
# ScriptName: Microsoft.Windows.Server.DNS.Zone.Discovery
#
# Purpose: DNS Server Zone Discovery
#
# File: Microsoft.Windows.Server.DNS.Zone.Discovery.ps1
#*************************************************************************
param (
[parameter(Mandatory=$false)]
[String] $ElementID = "$MPElement$",
[parameter(Mandatory=$false)]
[String] $TargetID="$Target/Id$",
[parameter(Mandatory=$false)]
[String] $ServerName = "$Target/Host/Property[Type='Windows!Microsoft.Windows.Computer']/PrincipalName$",
[parameter(Mandatory=$false)]
[String] $ServerVersion = "$Target/Property[Type='Microsoft.Windows.DNSServer.2016.Server']/WindowsVersion$"
)

Function Start-Initialization
{
Set-Variable momApi -value $null -Scope Script

Set-Variable EVENT_TYPE_LOG -value 0 -Scope Script -Option Constant
Set-Variable EVENT_TYPE_ERROR -value 1 -Scope Script -Option Constant
Set-Variable EVENT_TYPE_WARNING -value 2 -Scope Script -Option Constant
Set-Variable EVENT_TYPE_INFORMATION -value 4 -Scope Script -Option Constant

Set-Variable EventSuccess -value 5700 -Scope Script -Option Constant
Set-Variable EventError -value 5701 -Scope Script -Option Constant
Set-Variable EventWarn -value 5702 -Scope Script -Option Constant
Set-Variable EventInfo -value 5704 -Scope Script -Option Constant

Set-Variable discoveryData -value $null -Scope Script


Set-Variable DnsZoneTypeName -value "$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone']$" -Scope Script
Set-Variable DnsGlobalZoneTypeName -value "$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone.Global']$" -Scope Script

Set-Variable DnsGlobalZoneIsActiveProp -value "$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone.Global']/IsActivated$" -Scope Script
Set-Variable DnsGlobalZoneQueryOrderProp -value "$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone.Global']/QueryOrder$" -Scope Script


Set-Variable DnsZoneNameProp -value "$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone']/ZoneName$" -Scope Script
Set-Variable DnsZoneTypeProp -value "$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone']/ZoneType$" -Scope Script
Set-Variable DnsZoneReverseProp -value "$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone']/IsReverseZone$" -Scope Script
Set-Variable DnsZoneADintegratedProp -value "$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone']/IsADIntegrated$" -Scope Script
Set-Variable DnsZoneDynUpdProp -value "$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone']/AllowDynamicUpdates$" -Scope Script
Set-Variable DnsZoneTransferProp -value "$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone']/AllowZoneTransfers$" -Scope Script
Set-Variable DnsZonePrimaryServerProp -value "$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone']/PrimaryServerName$" -Scope Script
Set-Variable DnsZoneFileNameProp -value "$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone']/ZoneFileName$" -Scope Script
Set-Variable DnsZoneWinsProp -value "$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone']/UseWINS$" -Scope Script
Set-Variable DnsZoneHostNameProp -value "$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone']/HostName$" -Scope Script
Set-Variable DnsZoneNameServersProp -value "$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone']/NameServers$" -Scope Script
Set-Variable DnsZoneMasterServersProp -value "$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone']/MasterServers$" -Scope Script
Set-Variable DnsZoneIsSignedProp -value "$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone']/IsSigned$" -Scope Script


Set-Variable SysDisplayNameProp -value "$MPElement[Name='System!System.Entity']/DisplayName$" -Scope Script
Set-Variable DNSNameProp -value "$MPElement[Name='Microsoft.Windows.DNSServer.2016.Server']/Name$" -Scope Script
Set-Variable CompNameProp -value "$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$" -Scope Script
Set-Variable SCRIPT_NAME -value "Microsoft.Windows.Server.DNS.Zone.Discovery.ps1" -Scope Script -Option Constant
Set-Variable DnsZoneDisplayName -value "Zone" -Scope Script -Option Constant
Set-Variable DnsZoneDisp -value "on" -Scope Script -Option Constant
Set-Variable DnsDelimiter -value " " -Scope Script -Option Constant
Set-Variable DnsMasterServersMaxSize -value 256 -Scope Script -Option Constant
Set-Variable DnsNameServersMaxSize -value 256 -Scope Script -Option Constant
Set-Variable DnsGlobalZoneName -value "globalnames" -Scope Script -Option Constant
Set-Variable DnsZoneSysDispNameMaxSize -value 256 -Scope Script -Option Constant

}

Function Set-EmptyDiscoveryData
{
$Script:discoveryData = $Script:momApi.CreateDiscoveryData(0, $Script:ElementID, $Script:TargetID )
$Script:discoveryData.IsSnapshot = $false
$Script:discoveryData
}

Function Start-SCOMobjectsInitialization
{
try
{
$Script:momApi = New-Object -ComObject Mom.ScriptAPI -ErrorAction Stop
$Script:discoveryData = $Script:momApi.CreateDiscoveryData(0, $Script:ElementID, $Script:TargetID )
$Script:discoveryData.IsSnapshot = $true
}
catch
{
if ($null -eq $Script:momApi)
{
exit -1
}
else
{
$ErrorMessage = Get-ErrorMessage -Exception $_.Exception
Set-Error -ScriptName $Script:SCRIPT_NAME -EventLevel $Script:EventError -EventType $Script:EVENT_TYPE_ERROR -ErrorMessage $ErrorMessage

exit
}

}

}

Function Get-ErrorMessage($Exception)
{
$Error = $Exception.Message
$ErrorMessage = @"
Module: $Script:SCRIPT_NAME

Error(s) was(were) occurred:
State:
The configuration properties are :
ServerName = $Script:ServerName
DiscoverySourceObjectId = $Script:ElementID
DiscoverySourceManagedEntityId = $Script:TargetID
Error(s):
$Error

"@

return $ErrorMessage
}

Function Start-Discovery
{

if([String]::IsNullOrEmpty($Script:ServerVersion) )
{
$Script:discoveryData

return
}

$GlZone = @{$true = "Global Zone First"; $false = "Local Zone First"}

try
{

if(-Not $Script:ServerVersion.StartsWith("10."))
{
$Script:discoveryData

return
}

$Zones = Get-DnsServerZone | where {$_.ZoneType -ne "Forwarder" -and $_.IsAutoCreated -eq $false}

foreach ($Zone in $Zones)
{
if ([String]::IsNullOrEmpty($Zone.ZoneName))
{
continue
}

if ([string]::Equals($Script:DnsGlobalZoneName,$Zone.ZoneName,[System.StringComparison]::InvariantCultureIgnoreCase) )
{
$GlobalZone = Get-DnsServerGlobalNameZone

if ($null -eq $GlobalZone)
{
continue
}

$IsGlobalZone = $GlobalZone.Enable
$GlobalOverLocal = $GlobalZone.GlobalOverLocal

if ($null -eq $IsGlobalZone)
{
$IsGlobalZone = $false
}

if ($null -eq $GlobalOverLocal)
{
$GlobalOverLocal = "Local Zone First"
}
else
{
$GlobalOverLocal = $GlZone[$GlobalOverLocal]
if ($null -eq $GlobalOverLocal)
{
$GlobalOverLocal = "Local Zone First"
}
}


$ZoneInstance = $Script:discoveryData.CreateClassInstance($Script:DnsGlobalZoneTypeName)
$ZoneInstance.AddProperty($Script:DnsGlobalZoneIsActiveProp,$IsGlobalZone)
$ZoneInstance.AddProperty($Script:DnsGlobalZoneQueryOrderProp,$GlobalOverLocal)

}
else
{
$ZoneInstance = $Script:discoveryData.CreateClassInstance($Script:DnsZoneTypeName)
}


$ZoneTransferType = Get-ZoneTransferType -ZoneType $Zone.SecureSecondaries
$ZoneMasterServers = Get-ZoneMasterServers -MasterServers $Zone.MasterServers -separator $Script:DnsDelimiter -MaxSize $Script:DnsMasterServersMaxSize
$ZoneNameServers = Get-NameServers -ZoneName $Zone.ZoneName -separator $Script:DnsDelimiter -MaxSize $Script:DnsMasterServersMaxSize
$PrimaryServer = Get-ZonePrimaryServer -ZoneName $Zone.ZoneName

$SysDispName = "$Script:DnsZoneDisplayName " + $Zone.ZoneName + " $Script:DnsZoneDisp $Script:ServerName"
if ($Script:DnsZoneSysDispNameMaxSize -lt $SysDispName.Length)
{
$SysDispName = $SysDispName.Substring(0,$Script:DnsZoneSysDispNameMaxSize)
}

$IsSigned = $false
if ($null -ne $Zone.IsSigned)
{
$IsSigned = $Zone.IsSigned
}

$ZoneInstance.AddProperty($Script:CompNameProp,$Script:ServerName)
$ZoneInstance.AddProperty($Script:DNSNameProp, $Script:ServerName)
$ZoneInstance.AddProperty($Script:DnsZoneNameProp,$Zone.ZoneName)
$ZoneInstance.AddProperty($Script:DnsZoneTypeProp,$Zone.ZoneType)
$ZoneInstance.AddProperty($Script:DnsZoneReverseProp,$Zone.IsReverseLookupZone)
$ZoneInstance.AddProperty($Script:DnsZoneADintegratedProp,$Zone.IsDsIntegrated)
$ZoneInstance.AddProperty($Script:DnsZoneDynUpdProp,$Zone.DynamicUpdate)
$ZoneInstance.AddProperty($Script:DnsZoneTransferProp,$ZoneTransferType)
$ZoneInstance.AddProperty($Script:DnsZonePrimaryServerProp,$PrimaryServer)
$ZoneInstance.AddProperty($Script:DnsZoneFileNameProp,$Zone.ZoneFile)
$ZoneInstance.AddProperty($Script:DnsZoneWinsProp,$Zone.IsWinsEnabled)
$ZoneInstance.AddProperty($Script:DnsZoneHostNameProp,$Script:ServerName)
$ZoneInstance.AddProperty($Script:DnsZoneNameServersProp,$ZoneNameServers)
$ZoneInstance.AddProperty($Script:DnsZoneMasterServersProp,$ZoneMasterServers)
$ZoneInstance.AddProperty($Script:DnsZoneIsSignedProp,$IsSigned)
$ZoneInstance.AddProperty($Script:SysDisplayNameProp,$SysDispName)
$Script:discoveryData.AddInstance($ZoneInstance)

}

$Script:discoveryData
}
catch
{
$ErrorMessage = Get-ErrorMessage -Exception $_.Exception
Set-Error -ScriptName $Script:SCRIPT_NAME -EventLevel $Script:EventError -EventType $Script:EVENT_TYPE_ERROR -ErrorMessage $ErrorMessage

Set-EmptyDiscoveryData
}
}

Function Get-ZoneTransferType([String]$ZoneType)
{

if ([String]::IsNullOrEmpty($ZoneType))
{
return 0;
}

$ZonTypes = @{
"notransfer" = 3;
"transferanyserver" = 1;
"transfertozonenameserver" = 1;
"transfertosecureservers" = 2
}

$ZoneType = $ZoneType.ToLower()
$ZoneTransferType = $ZonTypes[$ZoneType]
if ($null -eq $ZoneTransferType)
{
$ZoneTransferType = 0
}

return $ZoneTransferType
}

Function Get-ZoneMasterServers($MasterServers,[String]$separator,$MaxSize)
{

$ResultString = [String]::Empty
if ($null -eq $MasterServers)
{
return $ResultString;
}

if ([String]::IsNullOrEmpty($separator))
{
$separator = $Script:DnsDelimiter

}

if ($null -eq $MaxSize)
{
$MaxSize = $Script:DnsMasterServersMaxSize
}


if($null -eq $MasterServers.Count)
{
$ArraySize = 1
}
else
{
$ArraySize = $MasterServers.Count
}

try
{
$IpStringArr = @(1..$ArraySize)

$ResultLength = 0
$index = 0

foreach ($MasterServer in $MasterServers)
{
if ( -Not [String]::IsNullOrEmpty($MasterServer.IPAddressToString) )
{
if (0 -eq $index)
{
$delta = $MaxSize - $ResultLength
}
else
{
$delta = $MaxSize - $ResultLength - $separator.Length
}


if($delta -lt $MasterServer.IPAddressToString.Length)
{
continue
}

$IpStringArr[$index] = $MasterServer.IPAddressToString
$ResultLength = $ResultLength + $MasterServer.IPAddressToString.Length

if ($index -gt 0)
{
$ResultLength = $ResultLength + $separator.Length
}

$index = $index + 1

}
}

if ($index -ne 0)
{
$ResultIpArr = @(1..$index)
[array]::Copy($IpStringArr,$ResultIpArr,$index)
$ResultString = [String]::Join($separator,$ResultIpArr)
}

}
catch
{
$ResultString = [String]::Empty
$ErrorMessage = Get-ErrorMessage -Exception $_.Exception
Set-Error -ScriptName $Script:SCRIPT_NAME -EventLevel $Script:EventWarn -EventType $Script:EVENT_TYPE_WARNING -ErrorMessage $ErrorMessage

}

return $ResultString
}

Function Get-ZoneNameServers($NameServers,[String]$separator,$MaxSize)
{

$ResultString = [String]::Empty

if ($null -eq $NameServers)
{
return $ResultString;
}

if ([String]::IsNullOrEmpty($separator))
{
$separator = $Script:DnsDelimiter
}

if ($null -eq $MaxSize)
{
$MaxSize = $Script:DnsMasterServersMaxSize
}

if($null -eq $NameServers.Count)
{
$ArraySize = 1
}
else
{
$ArraySize = $NameServers.Count
}

try
{
$StringArr = @(1..$ArraySize)

$ResultLength = 0
$index = 0

foreach ($NameServer in $NameServers)
{
if ( -Not [String]::IsNullOrEmpty($NameServer) )
{
if (0 -eq $index)
{
$delta = $MaxSize - $ResultLength
}
else
{
$delta = $MaxSize - $ResultLength - $separator.Length
}

if($delta -lt $NameServer.Length)
{
continue
}

$StringArr[$index] = $NameServer
$ResultLength = $ResultLength + $NameServer.Length
if ($index -gt 0)
{
$ResultLength = $ResultLength + $separator.Length
}

$index = $index + 1

}
}

if ($index -ne 0)
{
$ResultArr = @(1..$index)
[array]::Copy($StringArr,$ResultArr,$index)
$ResultString = [String]::Join($separator,$ResultArr)
}

}
catch
{
$ResultString = [String]::Empty
$ErrorMessage = Get-ErrorMessage -Exception $_.Exception
Set-Error -ScriptName $Script:SCRIPT_NAME -EventLevel $Script:EventWarn -EventType $Script:EVENT_TYPE_WARNING -ErrorMessage $ErrorMessage

}

return $ResultString
}

Function Get-NameServers ([String]$ZoneName,[String]$separator,$MaxSize )
{
$NameServers = [String]::Empty

if ([String]::IsNullOrEmpty($ZoneName))
{
return $NameServers
}

$NsArray = @()
try
{
$NsRecords = Get-DnsServerResourceRecord -ZoneName $ZoneName -RRType Ns -Node
foreach($NsRecord in $NsRecords)
{
if ([String]::IsNullOrEmpty($NsRecord.RecordData.NameServer))
{
continue
}

if (1 -eq $NsRecord.RecordData.NameServer.Length)
{
continue
}

$NsArray += $NsRecord.RecordData.NameServer.Substring(0,$NsRecord.RecordData.NameServer.Length - 1)

}

[array]::Sort($NsArray)
$NameServers = Get-ZoneNameServers -NameServers $NsArray -separator $separator -MaxSize $MaxSize
}
catch
{
$NameServers = [String]::Empty
$ErrorMessage = Get-ErrorMessage -Exception $_.Exception
Set-Error -ScriptName $Script:SCRIPT_NAME -EventLevel $Script:EventWarn -EventType $Script:EVENT_TYPE_WARNING -ErrorMessage $ErrorMessage

}


return $NameServers

}

Function Get-ZonePrimaryServer([String]$ZoneName)
{
$PrimaryServer = ""

if ([String]::IsNullOrEmpty($ZoneName))
{
return $PrimaryServer;
}


try
{
$NsRecords = Get-DnsServerResourceRecord -ZoneName $ZoneName -RRType Soa -Node
foreach($NsRecord in $NsRecords)
{
if ([String]::IsNullOrEmpty($NsRecord.RecordData.PrimaryServer))
{
continue
}

if (1 -eq $NsRecord.RecordData.PrimaryServer.Length)
{
continue
}

$PrimaryServer = $NsRecord.RecordData.PrimaryServer.Substring(0,$NsRecord.RecordData.PrimaryServer.Length - 1)

}

}
catch
{
$PrimaryServer = [String]::Empty
$ErrorMessage = Get-ErrorMessage -Exception $_.Exception
Set-Error -ScriptName $Script:SCRIPT_NAME -EventLevel $Script:EventWarn -EventType $Script:EVENT_TYPE_WARNING -ErrorMessage $ErrorMessage
}

return $PrimaryServer
}

Function Set-Error([String]$ErrorMessage,$EventLevel,$EventType,[String]$ScriptName)
{
if ($null -eq $Script:momApi)
{
return
}

try
{
$Script:momApi.LogScriptEvent($ScriptName,$EventLevel,$EventType,$ErrorMessage)

}
catch
{
}

}

Function Import-CmdLets ()
{
try
{
$dnsmodule = Get-Module -Name "DnsServer"
if ($null -eq $dnsmodule)
{
Import-Module DnsServer
}
}
catch [System.IO.FileNotFoundException]
{
$ErrorMessage = "Dns cmdlets doesn't exist."
Set-Error -ScriptName $Script:SCRIPT_NAME -EventLevel $Script:EventError -EventType $Script:EVENT_TYPE_ERROR -ErrorMessage $ErrorMessage
exit
}
catch
{
$ErrorMessage = Get-ErrorMessage -Exception $_.Exception
Set-Error -ScriptName $Script:SCRIPT_NAME -EventLevel $Script:EventError -EventType $Script:EVENT_TYPE_ERROR -ErrorMessage $ErrorMessage
exit
}
}

$ErrorActionPreference = "Stop"

$Script:ElementID = $ElementID
$Script:TargetID = $TargetID
$Script:ServerName = $ServerName
$Script:ServerVersion = $ServerVersion

Start-Initialization
Start-SCOMobjectsInitialization
Import-CmdLets
Start-Discovery
</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>ElementID</Name>
<Value>$MPElement$</Value>
</Parameter>
<Parameter>
<Name>TargetID</Name>
<Value>$Target/Id$</Value>
</Parameter>
<Parameter>
<Name>ServerName</Name>
<Value>$Target/Host/Property[Type='Windows!Microsoft.Windows.Computer']/PrincipalName$</Value>
</Parameter>
<Parameter>
<Name>ServerVersion</Name>
<Value>$Target/Property[Type='Microsoft.Windows.DNSServer.2016.Server']/WindowsVersion$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</Discovery>