Script for Multi/Sub-Object Material ID en masse?

Is there a recommended script for setting the Material ID surface property to a bunch of objects at once? There’s a couple I see that may work, but any recommendations?