After doing the lab test, the following script may meet your needs, it can list the devices that do not install the specified product:
InstalledSoftware | where SoftwareCode != '{C1198F10-5A16-4E9A-98B4-7554CC262ACC}' | summarize dcount(Device) by Device
(You can change the software code if you need.)
Hope it can help you.
If the response is helpful, please click "Accept Answer"and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.