7 Replies Latest reply on May 15, 2018 1:41 PM by JBartholomew

    Issues with Global get-tagassigment

    JBartholomew Novice

      We recently started running into an issue in one of our vCenters with a script that I had written to grab the inventory of VMs in our environment including the Tags associated with the VMs. We have 3 vCenters, all running 6.5, and 2 of the 3 vCenters run the script fine, but when we run the script against the 3rd vCenter, we get an error:

      Get-TagAssignment : 5/14/2018 4:40:31 PM        Get-TagAssignment               com.vmware.vapi.std.errors.internal_server_error {'messages': [com.vmware.vapi.std.localizable_message {'id':
      vapi.bindings.method.impl.unexpected, 'default_message': Provider method implementation threw unexpected exception: Read timed out, 'args': [Read timed out]}], 'data':}

      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.Comma
         nds.Tagging.GetTagAssignment

      The vCenter with the issues is our largest site, and has the most tags, so I believe we have possibly hit a limit of the number of results get-tagassignment can return as this script worked fine until a week ago when we added some more tags to the VMs.

      I have looked at a few other threads on here, and in one of them LucD recommended using his rCIS module to get around a very similar issue. I have attempted to run the rCIS module and am getting an error with it as well:

      Get-View : 5/14/2018 4:39:19 PM Get-View                You are not currently connected to any servers. Please connect first using a Connect cmdlet.
      At FileLocation\Projects\VMWare\rCisTag\rCisTag.psm1:408 char:35
      + ...                   Entity = (Get-View -id $sMoRef -Property Name).Name
      +                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : ResourceUnavailable: (:) [Get-View], ViServerConnectionException
          + FullyQualifiedErrorId : Core_BaseCmdlet_NotConnectedError,VMware.VimAutomation.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView

      I have verified that both get-tag and get-rcistag works fine, and using either get-tagassigment or get-rcistagassignment using the -entity filter works, but using either without a filter fails. unfortunately due to the way the code was written, using a filter on the get-tagassignment isnt easy to re-write

      Below is the section of code that is calling the get-tagassignment and failing

       

      foreach($tag in (Get-TagAssignment)){
          $tagCat += $tag.Tag.Category.Name
          $key = $tag.Entity.Name
          if($tagTab.ContainsKey($key)){
          ` $val = $tagTab.Item($key)
          }
          else{
              $val = @{}
          }
          $val.Add($tag.Tag.Category.Name,$tag.Tag.Name)
          $tagTab[$key] = $val
      }

      any assistance would be greatly appreciated

        • 1. Re: Issues with Global get-tagassigment
          LucD Guru
          User ModeratorsvExpertCommunity Warriors

          Are you able to restart that vCenter?

          Which PowerCLI version are you running?

          • 2. Re: Issues with Global get-tagassigment
            JBartholomew Novice

            VCSA has been restarted, and now the Get-rCISTagassigment is returning results, but it is taking quite a long time to return results

             

            > Measure-Command {Get-rCisTagAssignment}

             

             

            Days              : 0

            Hours             : 0

            Minutes           : 7

            Seconds           : 16

            Milliseconds      : 170

            Ticks             : 4361700549

            TotalDays         : 0.00504826452430555

            TotalHours        : 0.121158348583333

            TotalMinutes      : 7.269500915

            TotalSeconds      : 436.1700549

            TotalMilliseconds : 436170.0549

             

            Here is the version info

             

            > $psversiontable

             

            Name                           Value

            ----                           -----

            PSVersion                      5.1.16299.251

            PSEdition                      Desktop

            PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}

            BuildVersion                   10.0.16299.251

            CLRVersion                     4.0.30319.42000

            WSManStackVersion              3.0

            PSRemotingProtocolVersion      2.3

            SerializationVersion           1.1.0.1

             

            get-powercliversion

            WARNING: The cmdlet "Get-PowerCLIVersion" is deprecated. Please use the 'Get-Module' cmdlet instead.

             

            PowerCLI Version

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

               VMware PowerCLI 10.1.0 build 8346946

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

            Component Versions

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

               VMware Cis Core PowerCLI Component PowerCLI Component 10.1 build 8377811

               VMware VimAutomation VICore Commands PowerCLI Component PowerCLI Component 10.1 build 8344055

             

             

             

            PS > get-module -name VMWare*

             

            ModuleType Version    Name                                ExportedCommands

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

            Script     6.7.0.8... VMware.Vim

            Script     10.1.0.... VMware.VimAutomation.Cis.Core       {Connect-CisServer, Disconnect-CisServer, Get-CisService}

            Script     10.1.0.... VMware.VimAutomation.Common

            Script     10.1.0.... VMware.VimAutomation.Core           {Add-PassthroughDevice, Add-VirtualSwitchPhysicalNetworkAd...

            Script     10.1.0.... VMware.VimAutomation.Sdk            {Get-InstallPath, Get-PSVersion}

             

            Now that the restart has gotten the rCIS Module to run, I am going to try to implement that in the script

            • 3. Re: Issues with Global get-tagassigment
              LucD Guru
              User ModeratorsCommunity WarriorsvExpert

              When you are on PowerCLI 10.1.0, you can use the Get-TagAssignment , no need to use the cmdlets from my rCisTag module.

              Curious if you see the same times with the PowerCLI native cmdlet (which also uses the REST API).

              • 4. Re: Issues with Global get-tagassigment
                JBartholomew Novice

                That is the issue, when I run Get-tagassignment against this particular VCSA it fails with the error in the original post. The other 2 VCSA's run get-tagassignment fine.

                • 5. Re: Issues with Global get-tagassigment
                  LucD Guru
                  User ModeratorsvExpertCommunity Warriors

                  I didn't get that.

                  So my Get-rCisTagAssignment does work against that vCenter?

                  • 6. Re: Issues with Global get-tagassigment
                    JBartholomew Novice

                    yes the get-rCISTagAssignment works against that vCenter after rebooting the VCSA, but the Get-Tagassignment does not. I am trying to schedule time to reboot the other VCSA's to see if I can get the rCIS to work their so I can get a comparison between runtimes on Get-Tagassignment and Get-rCISTagassignment

                    • 7. Re: Issues with Global get-tagassigment
                      JBartholomew Novice

                      So I am ultimately not sure why the Global Get-tagassignment has stated failing in this vCenter, but I have worked around the problem by calling the Get-tagassignment on a per VM basis using:

                       

                      Foreach ($vm in $vms) {

                          $VMTags += Get-TagAssignment -Entity $vm.name

                          }

                       

                      I had implemented the get-rcistagassignment in the code and it was failing out on VMs without any tags, so I felt that this was a reasonable work around in the mean time.

                       

                      I should probably go back through the entire script to see if it can be streamlined, but at this point I dont really have a lot of time to re-write something that works.