This is the correct method to prevent VMs from being published. As mentioned it is all or nothing. If inventory has already been published, then steps will need to be taken to remove those from inventory.
Note: It is not possible to exclude individual VMs, so we usually recommend customers create a uim monitoring user in the ESX environment and only allow specific machines to be monitored in that case.