VMware Cloud Community
dbailey12
Contributor
Contributor

Weird Get-TagAssignment bug

I've got two VCSAs at 6.5 build 5705665. When I run the following, I get the error noted below:

Commads:

Connect-VIServer vcsa1.blah.local

Connect-VIServer vcsa2.blah.local

$VCTags = Get-TagAssignment -Server vcsa1.blah.local

Output:

Name                           Port  User                         

----                           ----  ----                         

vcsa1.blah.local  443   BLAH\user           

vcsa2.blah.local  443   BLAH\user           

Get-TagAssignment : 6/22/2017 1:55:51 PM Get-TagAssignment Sequence contains more than one matching element

At line:4 char:12

+ $VCBTags = Get-TagAssignment -Server vcsa1.blah.local

+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-TagAssignment], CisException

    + FullyQualifiedErrorId : VMware.VimAutomation.ViCore.Impl.V1.Service.Tagging.Cis.TaggingServiceCisImpl.GetTagAssignment.Error,VMware.VimAutomation.ViCore.Cmdlets.C

   ommands.Tagging.GetTagAssignment

I can disconnect from vcsa2 and run the Get-TagAssignment cmdlet successfully against vcsa1. The error only occurs when simultaneously connected to these two servers. I have one other 6.5 build 5705665 VCSA and any combination with it and the other two doesn't result in the error. I also have some 5.5 vCenters on Windows and can't reproduce the error with any combination of those and 6.5 servers.

I've reproduced from Windows Server 2012 R2 (PowerShell 4.0, PowerCLI 6.5R1) and Windows Server 2016 (PowerShell 5.1, PowerCLI 6.5.1).

Can anyone else reproduce this?

Message was edited by: dbailey12

Reply
0 Kudos
8 Replies
LucD
Leadership
Leadership

Do you also get the error when you add the Entity parameter, referring to one or more specific VIObjects?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
sbarry
Contributor
Contributor

I get this exact same error when I try to use a Get cmdlet using the -tag parameter.  My environment is an enhanced linked mode configuration with 3 vCenter/PSC servers participating.  I get the error when connecting to two vCenter servers, but not the third. 

For example:

PS C:\Windows\system32> $Tag = Get-Tag "Template"

PS C:\Windows\system32> Get-Cluster -Tag $Tag

Get-Cluster : 6/20/2017 10:41:05 AM Get-Cluster Sequence contains more than one element

At line:1 char:1

+ Get-Cluster -Tag $Tag

+ ~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-Cluster], CisException

    + FullyQualifiedErrorId : ViCore.Impl.V1.Service.Tagging.Cis.TaggingServiceCisImpl.GetObjectIdListByTag.Error,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetCluster

Reply
0 Kudos
sbarry
Contributor
Contributor

To be thorough, I just tested the Get-TagAssignment cmdlet and it throws the same error as mentioned in the OP:

PS C:\Windows\system32> Get-TagAssignment

Get-TagAssignment : 6/23/2017 10:13:13 AM Get-TagAssignment Sequence contains no matching element

At line:1 char:1

+ Get-TagAssignment

+ ~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-TagAssignment], CisException

    + FullyQualifiedErrorId : VMware.VimAutomation.ViCore.Impl.V1.Service.Tagging.Cis.TaggingServiceCisImpl.GetTagAssignment.Error,VMware.VimAutomation.ViCore.Cmdlets.Commands.Tagging.GetTagAssignment

Reply
0 Kudos
sbarry
Contributor
Contributor

I tried performing a get-tagassignment on entities and what I've tested works for me.

Foreach($Entity in Get-Cluster){Get-TagAssignment -Entity $Entity}

Foreach($Entity in Get-Datastore){Get-TagAssignment -Entity $Entity}

Reply
0 Kudos
LucD
Leadership
Leadership

This definitely looks like a bug, I suggest to open a SR for this.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
sbarry
Contributor
Contributor

Yeah I already have one open, but it's been slow to get traction.  I'll escalate it to see if it gets moving.

Reply
0 Kudos
SCampbell1
Enthusiast
Enthusiast

This may be useful to me too as I'm having a similar error with Get-TagAssignment. ("sequence contains no matching element")

The version of PowerCLI may also be useful for troubleshooting.

I am running:

Name                          Version

----                          -------

VMware.VimAutomation.Cis.Core 6.5.1.5374323

VMware.VimAutomation.Common   6.5.1.5335010

VMware.VimAutomation.Core     6.5.1.5374329

VMware.VimAutomation.Sdk      1.0.0.5334677

Update.

After further exploration, this error is occurring for me on a Standard VirtualPortGroup entity which does not appear in the network pane.  (vMotion and Management Network).  This is repeatable for other vCenters which don't use dvSwitches.

This worked around my problem:

Get-VirtualPortGroup -Standard | Where-Object { $_.ExtensionData.Port.Type -ne "host" } | Get-TagAssignment

Reply
0 Kudos
JoshF0
Contributor
Contributor

Did you get any traction with your SR?

I get "no matching element" errors too.  I have see issues where having two connected VIservers cause similar issues with tags as well.  I can now get "Sequence contains no matching element" on my second command of the session. I will add that this same command work in an old virtual center in the same powercli session, and that a tag is indeed assigned to that datastore.  The odd part is powerCLI is how all the tags got set in the first place when I built out this new vCenter. 

[1]: Connect-VIServer vcenter.fqdn    # Logon as THE vsphere.local\administrator

[2]: Get-TagAssignment -Entity (get-datastore NameofaSingleDatastore)

Get-TagAssignment : 9/22/2017 11:14:20 AM       Get-TagAssignment               Sequence contains no matching element

At line:1 char:1

+ Get-TagAssignment -Entity (get-datastore NameofaSingleDatastore)

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-TagAssignment], CisException

    + FullyQualifiedErrorId : VMware.VimAutomation.ViCore.Impl.V1.Service.Tagging.Cis.TaggingServiceCisImpl.GetTagAssi

   gnment.Error,VMware.VimAutomation.ViCore.Cmdlets.Commands.Tagging.GetTagAssignment

VCSA 6.5.0.10000 build 5973321

PowerCLI Version

----------------

   VMware PowerCLI 6.5.1 build 5377412

---------------

Component Versions

---------------

   VMware Cis Core PowerCLI Component 6.5 build 6230110

   VMware VimAutomation Core PowerCLI Component 6.5 build 6234650

   VMware Vds PowerCLI Component 6.5 build 5374428

   VMware Cloud PowerCLI Component 6.5 build 5375799

   VMware HA PowerCLI Component 6.0 build 5314477

   VMware HorizonView PowerCLI Component 7.1.0 build 5307191

   VMware Licensing PowerCLI Component 6.5 build 5375648

   VMware PCloud PowerCLI Component 6.5 build 5376282

   VMware SRM PowerCLI Component 6.5 build 5374694

   VMware Storage PowerCLI Component 6.5 build 5374001

   VMware vROps PowerCLI Component 6.5 build 5375723

   VMware vSphere Update Manager PowerCLI 6.6 build 5301639

Reply
0 Kudos