How can I list only sites that use a particular theme or plugin?

I need to search through dozens of WordPress multisite (network enabled) installs for sites that use a particular plugin.

How can I list only sites that use a particular theme or plugin, preferably with either WP CLI or a database query?