Author Posts

May 9, 2017 at 1:30 pm

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

May 9, 2017 at 2:01 pm

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

May 9, 2017 at 2:28 pm

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.

May 9, 2017 at 3:41 pm

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