Set oAPI = CreateObject("MOM.ScriptAPI")
Set oDiscoveryData = oAPI.CreateDiscoveryData(0, SourceId, ManagedEntityId)
Set objWMINS = GetObject("winmgmts://./root/cimv2")
Set colItems = objWMINS.ExecQuery("Select * from Win32_Service")
SpoolerStarted = 0
PrintServer = 0
For each oService in colItems
If oService.Name = "Spooler" and oService.Started = "True" Then
SpoolerStarted = 1
End If
Next
If SpoolerStarted = 1 Then
Set colItems = objWMINS.ExecQuery("Select * from Win32_Printer")
For Each oPrinter in colItems
'SET TO False and 0 FOR TESTING, True and 1 FOR PRODUCTION
If oPrinter.Shared = "True" or oPrinter.Shared = 1 Then
PrintServer = 1
End If
Next
End If
If SpoolerStarted = 1 and PrintServer = 1 Then
Select Case OSVersion
CASE "2003"
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Tasty.Printer.Monitoring.Windows2003.PrintServer.Role']$")
CASE "2008"
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Tasty.Printer.Monitoring.Windows2008.PrintServer.Role']$")
CASE "2012"
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Tasty.Printer.Monitoring.Windows2012.PrintServer.Role']$")
CASE "2016"
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Tasty.Printer.Monitoring.Windows2016.PrintServer.Role']$")
End Select
Call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$",TargetComputer)
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$",TargetComputer)
Call oDiscoveryData.AddInstance(oInst)
End If