Need help with report for all installed printers

etippett
Contributor II

I'm trying to figure out how to generate a report of all printers installed on all computers. Basically it would sort by the printer name and then show any computer with that printer installed. Given the options in the General and Display Fields areas of the advanced Computer search, I'm not seeing a way to do this. Does anyone have an idea?

Thanks,
Eric

6 REPLIES 6

mm2270
Legendary Contributor III

There are only two ways I can think of doing this. As you correctly noted, there is no display field option to show printers, unfortunately.

One way, which could take a long while depending on how many printers you have, would be to run a bunch of separate reports, one for each printer being recorded by Casper.

1- In an Advanced Search, under Receipts Information, choose Mapped Printers > Has > and use the ellipses button to pick the first printer in the list.
2- Set up your display fields to show only the computer name and any other info you want in the report.
3- Run the report, export out to a csv.
4- Rename the exported csv to the name of the printer so you can keep track of it.

Now do the same thing again, but choose the next printer down the list, export again, rename it.
Repeat the above for each printer, then take all those exported reports, open them in Excel and merge them together. Its goingt o ba a PITA to do it this way, but it will get you one Excel file that will show the Macs with the printers they are mapped to. You can sort it by the computer names to make sure the same Mac with multiple printers will show up sequentially.

The other option would be to create an Extension Attribute in your Inventory collection options. Running a command to collect the printers the Mac is mapped to and dropping that into a custom database field.
Once all your Macs have reported this information in, you can run a report with just the EA selected in the display fields and the Mac names to get your report.

The problem with option 2 is that it will take time to collect all this information because each Mac has to check in with an inventory report. You can try forcing them to submit inventory with Casper Remote, but you're bound to miss some that are offline or off the network, etc. You also have to create the EA and test it to make sure its pulling the proper information.

hope the above helps.

tlarkin
Honored Contributor

Hi Eric,

I did this recently for a customer that wanted the same functionality while doing an onsite jumpstart. It isn't the most elegant of solutions but it did seem to work. I basically created an extension attribute to grab all the installed PPD files locally on a Mac.

example output:

$ ls -l /etc/cups/ppd/ | awk '{ print $9 }'

EC_1Fl_Kyocera.ppd
EC_2Fl_Kyocera.ppd
MSP_N_10FL_Kyocera.ppd
MSP_W_10FL_Kyocera.ppd
Samsung_ML_2950_Series__SEC001599A32FE6_.ppd

You could take that output and put it into an Extension Attribute and then it can be added to a device in inventory. The receipts in /Library/Receipts will track if the drivers are installed, not if the printer is actually mapped.

mm2270
Legendary Contributor III

The following will also pull any mapped printers, even ones that are in a paused state. its not the same exact name as what shows up in the Print & Scan Prefpane, but close enough in most cases-

lpstat -p | awk '{print $2}' | sed '/^$/d'

rockpapergoat
Contributor III

you could change that to

lpstat -a | awk '{print $1}'

to avoid deleting blank lines with sed.

mm2270
Legendary Contributor III

Yeah you're right. Since the printer names will never have spaces in them, that would work.

etippett
Contributor II

FYI here's what I ended up using for an extension attribute.

#!/bin/sh

echo "<result>$(lpstat -t | grep "device for" | awk -F "device for " '{print $2}')</result>"