PowerShell Script to query and delete print jobs older than “x” days

Question:

I started putting this PowerShell Script together, the hope would be to replace some tasks that are currently carried out manually

I’m using the

function

I’m using the ISE to build the script and in testing I get output if I single out the ‘starttime’ property, but this seems to be a catch all because the values all come up null, ideally I’d like to use the ‘timesubmitted’ property, but the date seems to output in an odd that I don’t think is being read correctly because my queries with ‘timesubmitted’ always come up empty

it comes out in this format, if you do an open query

here’s what I have so far.

disregard the | ‘format-table’ function that’s just so I can see if I’m getting the desired output

Answer:

In PowerShell every WMI instance has a ScriptMethod that you can use to convert the dates from WMI format to .NET format:

Source:

PowerShell Script to query and delete print jobs older than “x” days by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply