Looking for correct powercli 5.5 syntax for New-TagAssignment -Tag when trying to assign a duplicate tag name in two different categories. I am running the command New-TagAssignment -Tag "Distributed Applications" -Entity vm01 and I receive the error 'The specified parameter 'Tag' expects a single value, but your name criteria 'Distributed Applications' corresponds to multiple values'. The reason for this error is correct. I.E. I have Distributed Applications in these categories below.
Name Category Description
---- -------- -----------
Distributed Applications ApplicationOwner
Distributed Applications ServerOwner
What is the correct syntax for New-TagAssignment -Tag to assign Distributed Applications out of the category "ServerOwner" to the -entity vm01? If this question has already been asked, please refer me to the answer. Thank you.
Try like this
$tag = Get-Tag -Name 'Distributed Applications' -Category ServerOwner
New-TagAssignment -Tag $tag -Entity vm01
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try like this
$tag = Get-Tag -Name 'Distributed Applications' -Category ServerOwner
New-TagAssignment -Tag $tag -Entity vm01
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This was exactly what I was looking for. Thank you. I.E. very readable. I took it one step further to assign both to the same vm.
$tagSO = Get-Tag -Name 'Distributed Applications' -Category ServerOwner
New-TagAssignment -Tag $tagSO -Entity vm01
$tagAO = Get-Tag -Name 'Distributed Applications' -Category ApplicationOwner
New-TagAssignment -Tag $tagAO -Entity vm01
Was also looking for this, ty
Another question on it: Is there a way to use $vms to the -entity ?
If i try it that way, i get " Specified method is not supported "
$tag = Get-Tag -Name 'Tagname' -Category "Category Name"
New-TagAssignment -Tag $tag -Entity $vms <<< is this possible somehow?
Changing Tags seems still not possible in V6.5, so we need to check if a tag exists and delete it first if we wanna change it, right?
I'm afraid not, the Entity parameter expects a single value, not an array.
Correct, remove + create is currently the only option.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you Luc
I found myself a way to reach my goal, so maybe its usefull for others aswell:
You can wrap this into a foreach loop like:
foreach ($vm in $vms) { New-TagAssignment -Tag $tag -Entity $vm }
Works for me :smileycool: