Any way of write a tag to a vm based on a service summary?

Actually I try to solve multiple things. but this Combining VM Usage to LUN / Volume usage in Vcenter should also be solvable with that.