Win32_PrintJob class question

Hello,

I have a question about the Win32_printJob class:

I’m running the command Get-CimInstance -ClassName Win32_printjob on a few print servers (Win 2016). Each of the print server has 50+ printers installed for labels printing (maybe thousands of labels are printed every day ), but when the results are listed, it seems that the list is incomplete. The list contains records that were generated every day, but only a few per day (not thousands like I would expect).

My question is : Does the class Win32_printJob contains instances for all print jobs that were processed on the server, or only for some ? And if it does it only for some, how does it decide which one to record.

Is there a way to record all the print jobs instances that were processed on the server in the Win32_printJob class ?

 

Regards,

Catalin Filip

 

It only provides information on current print jobs. For history I believe you need to enable print event logging and then query/look through the events.

[quote quote=279336]It only provides information on current print jobs. For history I believe you need to enable print event logging and then query/look through the events.

[/quote]
The output from Get-CimInstance -ClassName Win32_printjob also contains very old printjobs (printed 6 months ago). The print spooler was restarted many times since 6 months ago, but the records are still kept. I’m wondering on which criteria it is choosing which jobs to store.

Sure, we can enable logging for printing. By default is disabled and we only enable/disable it for troubleshooting.

When I found the Win32_printjob class, I thought it will be a more easy and elegant way to extract the info about the printjobs.

 

Well I’d say there is something else going on because it is not supposed to show completed jobs from my understanding. Maybe they are still pending or paused. Good luck.

I do believe you need to enable “Keep printed documents” under Printer Properties/Advanced. That is what I ran into when I wrote a script to gather printed documents on local workstations. The problem in your case for print servers is the obvious, the documents reside on the local file system until purged. With thousands of print jobs/day, this is not an option for you unless you purge the queue daily.

The primary driver for me was to get the name of the document printed. With logging to the standard windows print log, you dont get that. What I would really love to obtain is the full file path of the document printed. I dont think that is possible, but if you figure that ou, please post your solution :slight_smile:

The Win32_PrintJob WMI class represents a print job generated by a Windows application. Any unit of work generated by the print command of an application that is running on a computer running on a Windows operating system is a descendant or member of this class.Most WMI classes return one or more instances.When Get-CimInstance returns no result, then apparently no instances of class Win32_PrintJob exist. This is normal behavior.

Either the class is not implemented on your system (may be deprecated or due to missing drivers, i.e. CIM_VideoControllerResolution), or there are simply no physical representations of this class currently available (i.e. Win32_TapeDrive).

I hope this helps!

Ben Martin

Apps4Rent

[quote quote=279498]Well I’d say there is something else going on because it is not supposed to show completed jobs from my understanding. Maybe they are still pending or paused. Good luck.

[/quote]
You are right, I found that the returned jobs are jobs that are on error (the printers may be offline).
I like the info that I get from running Get-CimInstance -ClassName Win32_printjob : JobId,PrinterName,Owner,Priority,DocumentSize,DocumentName,DriverName,DataType,PrintProcessor.TotalPages,TimeSubmitted.

Now I’m wondering if there is a way to capture the same information about each job as it is processed.

Thank you!

[quote quote=279939]I do believe you need to enable “Keep printed documents” under Printer Properties/Advanced. That is what I ran into when I wrote a script to gather printed documents on local workstations. The problem in your case for print servers is the obvious, the documents reside on the local file system until purged. With thousands of print jobs/day, this is not an option for you unless you purge the queue daily.

The primary driver for me was to get the name of the document printed. With logging to the standard windows print log, you dont get that. What I would really love to obtain is the full file path of the document printed. I don’t think that is possible, but if you figure that ou, please post your solution 🙂

[/quote]

I cannot afford to enable “Keep printed documents” on the server. Maybe I can do it for a few printer for troubleshooting or tracking the jobs for a limited amount of time.

Running Get-CimInstance -ClassName Win32_printjob you will get the name of the document and much more: JobId,PrinterName,Owner,Priority,DocumentSize,DocumentName,DriverName,DataType,PrintProcessor.TotalPages,TimeSubmitted.

Unfortunately you get it only for jobs on error.

 

[quote quote=280851]The Win32_PrintJob WMI class represents a print job generated by a Windows application. Any unit of work generated by the print command of an application that is running on a computer running on a Windows operating system is a descendant or member of this class.Most WMI classes return one or more instances.When Get-CimInstance returns no result, then apparently no instances of class Win32_PrintJob exist. This is normal behavior.

Either the class is not implemented on your system (may be deprecated or due to missing drivers, i.e. CIM_VideoControllerResolution), or there are simply no physical representations of this class currently available (i.e. Win32_TapeDrive).

I hope this helps!

Ben Martin

Get-CimInstance -ClassName Win32_printjob returns results, but as I found out it does it only for jobs on error.

The class should have been named Win32_PrintJobOnError :slight_smile:

Thank you!

Catalin Filip

Apps4Rent

[/quote]

Running Get-CimInstance -ClassName Win32_printjob you will get the name of the document and much more: JobId,PrinterName,Owner,Priority,DocumentSize,DocumentName,DriverName,DataType,PrintProcessor.TotalPages,TimeSubmitted.

Unfortunately you get it only for jobs on error.


 

You can also get the info if you keep documents as I stated before. I know this is not an option for you on servers. The script I use also purges the documents and we run it weekly on client systems. Our primary focus is on getting document names.