Windows Server 2016 and 1709+ Print Services Printer Object Discovery

Microsoft.Windows.Server.10.0.PrintServer.Printer.Discovery (Discovery)

Discovers all Windows Server 2016 and 1709+ Print Services Printers

Knowledge Base article:

Summary

Discovers all Windows Server 2016 and 1709+ Print Services Printer Queues

Element properties:

TargetMicrosoft.Windows.Server.10.0.PrintServerRole
EnabledTrue
Frequency14400
RemotableFalse

Object Discovery Details:

Discovered Classes and their attribuets:

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource Microsoft.Windows.TimedScript.DiscoveryProvider Default

Source Code:

<Discovery ID="Microsoft.Windows.Server.10.0.PrintServer.Printer.Discovery" Enabled="true" Target="Microsoft.Windows.Server.10.0.PrintServerRole" ConfirmDelivery="false" Remotable="false" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="Microsoft.Windows.Server.10.0.PrintServer.Printer">
<Property PropertyID="Attributes"/>
<Property PropertyID="Caption"/>
<Property PropertyID="DeviceID"/>
<Property PropertyID="Name"/>
<Property PropertyID="Path"/>
<Property PropertyID="PortName"/>
<Property PropertyID="Shared"/>
<Property PropertyID="ShareName"/>
<Property PropertyID="SpoolEnabled"/>
<Property PropertyID="Version"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
</DiscoveryTypes>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedScript.DiscoveryProvider">
<IntervalSeconds>14400</IntervalSeconds>
<SyncTime/>
<ScriptName>Printer.vbs</ScriptName>
<Arguments>$MPElement$ $Target/Id$ $Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$ $Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetbiosComputerName$</Arguments>
<ScriptBody><Script>Option Explicit
SetLocale("en-us")

Dim oArgs, SourceID, ManagedEntityId, TargetComputer, NetbiosName, oAPI, oDiscoveryData, oInst, objSet, obj, name, value, status
Set oArgs = WScript.Arguments
If oArgs.Count &lt; 4 Then
Wscript.Quit -1
End If

SourceID = oArgs(0)
ManagedEntityId = oArgs(1)
TargetComputer = oArgs(2)
NetbiosName = oArgs(3)

Set oAPI = CreateObject("MOM.ScriptAPI")
Set oDiscoveryData = oAPI.CreateDiscoveryData(0, SourceID, ManagedEntityId)

Set objSet = GetObject("winmgmts:\\" &amp; TargetComputer &amp; "\").InstancesOf("Win32_Printer")

For Each Obj in objSet

Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Microsoft.Windows.Server.10.0.PrintServer.Printer']$")

Call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", TargetComputer)

name = CStr(Getvalue("Name", obj)) &amp; " (" &amp; NetbiosName &amp; ")"
Call oInst.AddProperty("$MPElement[Name='Microsoft.Windows.Server.10.0.PrintServer.Printer']/Name$", name) ' Key Attribute

' value = Getvalue("Version", obj)
' if not(IsNull(value)) then Call oInst.AddProperty("$MPElement[Name='Microsoft.Windows.Server.10.0.PrintServer.Printer']/Version$", CStr(value))

value = Getvalue("Attributes", obj)
if not(IsNull(value)) then Call oInst.AddProperty("$MPElement[Name='Microsoft.Windows.Server.10.0.PrintServer.Printer']/Attributes$", CStr(value))

value = Getvalue("Caption", obj)
if not(IsNull(value)) then Call oInst.AddProperty("$MPElement[Name='Microsoft.Windows.Server.10.0.PrintServer.Printer']/Caption$", CStr(value))

value = Getvalue("DeviceID", obj)
if not(IsNull(value)) then Call oInst.AddProperty("$MPElement[Name='Microsoft.Windows.Server.10.0.PrintServer.Printer']/DeviceID$", CStr(value))

value = Getvalue("PortName", obj)
if not(IsNull(value)) then Call oInst.AddProperty("$MPElement[Name='Microsoft.Windows.Server.10.0.PrintServer.Printer']/PortName$", CStr(value))

value = Getvalue("Shared", obj)
if not(IsNull(value)) then Call oInst.AddProperty("$MPElement[Name='Microsoft.Windows.Server.10.0.PrintServer.Printer']/Shared$", CStr(value))

value = Getvalue("ShareName", obj)
if not(IsNull(value)) then Call oInst.AddProperty("$MPElement[Name='Microsoft.Windows.Server.10.0.PrintServer.Printer']/ShareName$", CStr(value))

value = Getvalue("SpoolEnabled", obj)
if not(IsNull(value)) then Call oInst.AddProperty("$MPElement[Name='Microsoft.Windows.Server.10.0.PrintServer.Printer']/SpoolEnabled$", CStr(value))


Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", name)
Call oDiscoveryData.AddInstance(oInst)

Next


Call oAPI.Return(oDiscoveryData)

function Getvalue(Name, obj)

Dim value

value = obj.Properties_.Item(Name).value

Getvalue=value

End Function</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</Discovery>