Win32_PrintJob class question

Welcome Forums General PowerShell Q&A Win32_PrintJob class question

Viewing 8 reply threads
  • Author
    Posts
    • #279141
      Participant
      Topics: 1
      Replies: 4
      Points: 30
      Rank: Member

      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

       

    • #279336
      Participant
      Topics: 9
      Replies: 706
      Points: 2,837
      Helping Hand
      Rank: Community Hero

      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.

    • #279408
      Participant
      Topics: 1
      Replies: 4
      Points: 30
      Rank: Member

      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.

      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.

       

    • #279498
      Participant
      Topics: 9
      Replies: 706
      Points: 2,837
      Helping Hand
      Rank: Community Hero

      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.

    • #279939
      Participant
      Topics: 10
      Replies: 201
      Points: 987
      Helping Hand
      Rank: Major Contributor

      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 🙂

      • #280973
        Participant
        Topics: 1
        Replies: 4
        Points: 30
        Rank: Member

        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 🙂

        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.

         

    • #280851
      Participant
      Topics: 0
      Replies: 5
      Points: 21
      Rank: Member

      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

    • #280967
      Participant
      Topics: 1
      Replies: 4
      Points: 30
      Rank: Member

      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.

      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!

      • This reply was modified 1 month ago by Pilif8361.
    • #280985
      Participant
      Topics: 1
      Replies: 4
      Points: 30
      Rank: Member

      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 🙂

      Thank you!

      Catalin Filip

      Apps4Rent

      • This reply was modified 1 month ago by Pilif8361.
    • #281609
      Participant
      Topics: 10
      Replies: 201
      Points: 987
      Helping Hand
      Rank: Major Contributor

      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.

      • This reply was modified 4 weeks, 1 day ago by TonyD.
Viewing 8 reply threads
  • You must be logged in to reply to this topic.