Tasty.Printer.Monitoring.Windows.2016.PrintServer.Printer.Discovery

Tasty.Printer.Monitoring.Windows.2016.PrintServer.Printer.Discovery (Discovery)

Description for the new discovery.

Element properties:

TargetTasty.Printer.Monitoring.Windows2016.PrintServer.Role
EnabledTrue
Frequency43200
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="Tasty.Printer.Monitoring.Windows.2016.PrintServer.Printer.Discovery" Target="Tasty.Printer.Monitoring.Windows2016.PrintServer.Role" Enabled="true" ConfirmDelivery="false" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="Tasty.Printer.Monitoring.Windows2016.PrintServer.Printer">
<Property TypeID="Tasty.Printer.Monitoring.Windows2016.PrintServer.Printer" PropertyID="PrinterName"/>
<Property TypeID="Tasty.Printer.Monitoring.Windows2016.PrintServer.Printer" PropertyID="PrintServerHost"/>
<Property TypeID="Tasty.Printer.Monitoring.Windows2016.PrintServer.Printer" PropertyID="PortName"/>
<Property TypeID="Tasty.Printer.Monitoring.Windows2016.PrintServer.Printer" PropertyID="Location"/>
<Property TypeID="Tasty.Printer.Monitoring.Windows2016.PrintServer.Printer" PropertyID="Model"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
</DiscoveryTypes>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedScript.DiscoveryProvider">
<!-- Set to something aggressive for testing or normally 3600-->
<IntervalSeconds>43200</IntervalSeconds>
<SyncTime/>
<ScriptName>WWindows20XX.PrintServer.Printer.Discovery.vbs</ScriptName>
<Arguments>$MPElement$ $Target/Id$ $Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$ $Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetbiosComputerName$ 2016</Arguments>
<ScriptBody><Script><![CDATA[' WWindows20XX.PrintServer.Printer.Discovery.vbs

Dim objWMIPrinters
Dim colItems
Dim oPrinter
Dim ErrorStateToString
Dim oAPI
Dim oExec
Dim LOgEVentCOmmand
Dim oArgs
Dim SourceID
Dim ManagedEntityID
Dim TargetComputer
Dim oInst
Dim oDiscoveryData
Dim NetbiosName
DIM OSVersion
'Prevents failure on error - it is possible some discovery data will not be present for some printers
'This clause will allow skipping of those errors to add the discovery data that is present.
On Error Resume Next

Set oArgs = wscript.arguments
SourceId = oArgs(0)
ManagedEntityID = oArgs(1)
TargetComputer = oArgs(2)
NetbiosName = oArgs(3)
OSVersion = oArgs(4)

Set oAPI = CreateObject("MOM.ScriptAPI")
Set oDiscoveryData = oAPI.CreateDiscoveryData(0, SourceId, ManagedEntityId)
Set objWMIPrinters = GetObject("winmgmts://./root/cimv2")
Set colItems = objWMIPrinters.ExecQuery("Select * from Win32_Printer")
'Set WshShell = CreateObject("Wscript.Shell")

For each oPrinter in colItems
' SET TO 1 FOR TESTING. REVERT TO 0 FOR PRODUCTION
If oPrinter.Shared = 0 Then
wscript.echo "Printer " & oPrinter.name & " is not shared. Ignored."
Else
wscript.echo "Printer " & oPrinter.name & " - " & ErrorStateToString

Select Case OSVersion
CASE "2003"
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Tasty.Printer.Monitoring.Windows2003.PrintServer.Printer']$")
Call oInst.AddProperty("$MPElement[Name='Tasty.Printer.Monitoring.Windows2003.PrintServer.Printer']/PrinterName$", oPrinter.name)
Call oInst.AddProperty("$MPElement[Name='Tasty.Printer.Monitoring.Windows2003.PrintServer.Printer']/PrintServerHost$", targetcomputer)
Call oInst.AddProperty("$MPElement[Name='Tasty.Printer.Monitoring.Windows2003.PrintServer.Printer']/PortName$", oPrinter.PortName)
Call oInst.AddProperty("$MPElement[Name='Tasty.Printer.Monitoring.Windows2003.PrintServer.Printer']/Location$", oPrinter.Location)
Call oInst.AddProperty("$MPElement[Name='Tasty.Printer.Monitoring.Windows2003.PrintServer.Printer']/Model$", oPrinter.DriverName)

CASE "2008"
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Tasty.Printer.Monitoring.Windows2008.PrintServer.Printer']$")
Call oInst.AddProperty("$MPElement[Name='Tasty.Printer.Monitoring.Windows2008.PrintServer.Printer']/PrinterName$", oPrinter.name)
Call oInst.AddProperty("$MPElement[Name='Tasty.Printer.Monitoring.Windows2008.PrintServer.Printer']/PrintServerHost$", targetcomputer)
Call oInst.AddProperty("$MPElement[Name='Tasty.Printer.Monitoring.Windows2008.PrintServer.Printer']/PortName$", oPrinter.PortName)
Call oInst.AddProperty("$MPElement[Name='Tasty.Printer.Monitoring.Windows2008.PrintServer.Printer']/Location$", oPrinter.Location)
Call oInst.AddProperty("$MPElement[Name='Tasty.Printer.Monitoring.Windows2008.PrintServer.Printer']/Model$", oPrinter.DriverName)

CASE "2012"
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Tasty.Printer.Monitoring.Windows2012.PrintServer.Printer']$")
Call oInst.AddProperty("$MPElement[Name='Tasty.Printer.Monitoring.Windows2012.PrintServer.Printer']/PrinterName$", oPrinter.name)
Call oInst.AddProperty("$MPElement[Name='Tasty.Printer.Monitoring.Windows2012.PrintServer.Printer']/PrintServerHost$", targetcomputer)
Call oInst.AddProperty("$MPElement[Name='Tasty.Printer.Monitoring.Windows2012.PrintServer.Printer']/PortName$", oPrinter.PortName)
Call oInst.AddProperty("$MPElement[Name='Tasty.Printer.Monitoring.Windows2012.PrintServer.Printer']/Location$", oPrinter.Location)
Call oInst.AddProperty("$MPElement[Name='Tasty.Printer.Monitoring.Windows2012.PrintServer.Printer']/Model$", oPrinter.DriverName)

CASE "2016"
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Tasty.Printer.Monitoring.Windows2016.PrintServer.Printer']$")
Call oInst.AddProperty("$MPElement[Name='Tasty.Printer.Monitoring.Windows2016.PrintServer.Printer']/PrinterName$", oPrinter.name)
Call oInst.AddProperty("$MPElement[Name='Tasty.Printer.Monitoring.Windows2016.PrintServer.Printer']/PrintServerHost$", targetcomputer)
Call oInst.AddProperty("$MPElement[Name='Tasty.Printer.Monitoring.Windows2016.PrintServer.Printer']/PortName$", oPrinter.PortName)
Call oInst.AddProperty("$MPElement[Name='Tasty.Printer.Monitoring.Windows2016.PrintServer.Printer']/Location$", oPrinter.Location)
Call oInst.AddProperty("$MPElement[Name='Tasty.Printer.Monitoring.Windows2016.PrintServer.Printer']/Model$", oPrinter.DriverName)

End Select

Call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", TargetComputer)
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", oPrinter.name)
Call oDiscoveryData.AddInstance(oInst)
End If
Next

Call oAPI.Return(oDiscoveryData)
]]></Script></ScriptBody>
<TimeoutSeconds>900</TimeoutSeconds>
</DataSource>
</Discovery>