Smart group by Printer URI?

jnovo
New Contributor

I'm looking for a way to create a smart group based on the URI of a printer.

For example, if the URI of a printer is ipp://127.0.0.1, I would want a smart group that looks for any printers with 127.0. in it.

Is this possible at all, maybe with an extension attribute?

1 ACCEPTED SOLUTION

Anonymous
Not applicable

You could create a smart group using the criteria "Printers Mapped is <nameOfPrinter>" but if you want to specifically target the URI then you would need an extension attribute. After a quick look, it would appear this would actually be pretty straightforward as we can utilize lpstat to get printer information from client machines. Here's a quick and dirty way you could do this:

#!/bin/sh
printerURI="ipp://127.0.0.1"
isInstalled="False"

if [ "$(lpstat -p -v | grep $printerURI)" ] ; then
    isInstalled="True"
fi

echo "<result>$isInstalled</result">

You can change printerURI to "printerURI=$4" and then define the printer URI within the JSS script parameters instead of hardcoding it. The above example is far from robust or exhaustive, but you get the idea :)

View solution in original post

2 REPLIES 2

Anonymous
Not applicable

You could create a smart group using the criteria "Printers Mapped is <nameOfPrinter>" but if you want to specifically target the URI then you would need an extension attribute. After a quick look, it would appear this would actually be pretty straightforward as we can utilize lpstat to get printer information from client machines. Here's a quick and dirty way you could do this:

#!/bin/sh
printerURI="ipp://127.0.0.1"
isInstalled="False"

if [ "$(lpstat -p -v | grep $printerURI)" ] ; then
    isInstalled="True"
fi

echo "<result>$isInstalled</result">

You can change printerURI to "printerURI=$4" and then define the printer URI within the JSS script parameters instead of hardcoding it. The above example is far from robust or exhaustive, but you get the idea :)

jnovo
New Contributor

Thanks! Solved.