Macleud
Enthusiast
Enthusiast

Try this. But if there is more than one VM with that name in  vCenter, it will assign a tag to all VMs with that name.

 

$VmTag = Get-Tag "TagName" 
Get-VM -Name $ChosenName | New-TagAssignment -Tag $VmTag