changing printer setting

This topic contains 3 replies, has 2 voices, and was last updated by  Daniel Krebs 5 months, 1 week ago.

  • Author
    Posts
  • #70363

    Justin Dietz
    Participant

    Hi. I need a little help here. We have a few old print servers and they want "keep printed jobs" turned on on all printers. The print servers are Server 2008. So printer management module is not available to me.

    I can see the property if i run

    get-wmiobject -class win32_printer -property keepprintedjobs

    However i can not figure out how to change this property. Everything i have tried has failed. I found VBScripts that can do this but i am determined to find the powershell way to do this.

    Also odd is is see "keepprintedjobs" as a property. But if put the above get-wmiobject into a variable (lets say $A)....and i then try to run
    $A.keepprintedjobs it yells that it is not a property that it can find. Can someone point me in the right direction.

    thank you

  • #70364

    Daniel Krebs
    Moderator

    Try the following, please:

    Get-WmiObject -Class Win32_Printer | Foreach-Object {
      $PSItem.KeepPrintedJobs = $true
      $PSItem.Put()
    }
    

    Let me know if it works.

    A bit more of an explanation. Your call of Get-WmiObject most likely returned an array of printer objects instead of just one. You'll need to loop over the array for example with Foreach-Object and update each object individually. However, just updating KeepPrintedJobs to True of each object won't change the printer queue configuration that is why you need to write it back to the printer server service with the Put() method.

    -Daniel

  • #70369

    Justin Dietz
    Participant

    excellent. that did work. thank you very much. I need to find some information on this Put() method as i have never used it before.

  • #70396

    Daniel Krebs
    Moderator

    Yeah. That is a bit of PowerShell magic in regards to WMI. You can see the method with

    $p = Get-WmiObject -Class Win32_Printer | Select-Object -First 1
    $p.psbase | Get-Member -MemberType Method
    

    MSDN documentation:
    https://msdn.microsoft.com/en-us/library/w09tfy94(v=vs.110).aspx

You must be logged in to reply to this topic.