This would allow people with multiple VMs that share the same name but have different UUIDS to then use Invoke-VMScript on indiviual machines. You can just add a -UUID after the -VM name option maybe?
Invoke-VMScript does not take VM name as an input. It takes a VM object. There is a special mechanism that allows users to pass a name, which is then converted to a VM object, but this mechanism should not be used when you have VMs with duplicating names. In this case you should use:
Get-VM -Id <vmid> | Invoke-VMScript
This will retrieve the VM by its id and then invoke the script on this VM.
Invoke-VMScript does not take VM name as an input. It takes a VM object. There is a special mechanism that allows users to pass a name, which is then converted to a VM object, but this mechanism should not be used when you have VMs with duplicating names. In this case you should use:
Get-VM -Id <vmid> | Invoke-VMScript
This will retrieve the VM by its id and then invoke the script on this VM.