14 Replies Latest reply on Jan 10, 2018 11:22 AM by LucD

    PowerCLI - New-TAG hangs in a script

    gertvangorp Enthusiast
    vExpert

      Hi,

       

      I a creating a script that needs to do  the following thing. 

      I us Sapien Powershell 2017 Editor for this because it has a form with info on it

      check if a TAG exists (GET-TAG)

       $TagInfo = Get-Tag -Name $paramClassName .  

      This works perfect.  I get the info of the TAG if it exists and a $null if the TAG does not exist.

      if the TAG does not exist, creat it.

      $MyClassTAG = Get-TagCategory -name "Class" | New-Tag -name $paramClassName  -Verbose -Debug -Confirm:$false

      The TAG is created but the script does not continue, it stays in the NEW-TAG cmdlet...

      with the VERBOSE option I get following output

      VERBOSE: 07/01/2018 22:43:01 New-Tag Started execution
      VERBOSE: Create tag 'ECCS-Classroom-GERTGERT-1' in category 'Class'
      VERBOSE: 07/01/2018 22:43:01 New-Tag Started execution
      VERBOSE: Create tag 'MyTAG' in category 'Class'

       

      The next command, writing a sttus update in a text filed is never executed.    if I comment out the NEW-TAG command line, the status is written correctly

       

      Working with lates vCenter 6.5  and ESXi, on a windows 10 machine with latest PowerCLI modules installed.

      PowerCLI Version                                                       

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

         VMware PowerCLI 6.5.1 build 5377412                                 

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

      Component Versions                                                     

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

         VMware Cis Core PowerCLI Component 6.5 build 6983166                

         VMware VimAutomation Core PowerCLI Component 6.5 build 6234650      

       

      Can someone tell me what I am doing wrong?

       

      Thanks

       

      Gert

        • 1. Re:PowerCLI - New-TAG hangs in a script
          gertvangorp Enthusiast
          vExpert

          By the way

           

          When I just open a powershell screen, connect to the vCenter, and execute following line

          Get-TagCategory "Class"| new-tag -name "gert"

          This works perfectly.

           

          Help this makes me crazy.

           

          Gert

           
          Get-TagCategory "Class"| new-tag -name "gert"
          • 2. Re:PowerCLI - New-TAG hangs in a script
            LucD Guru
            Community WarriorsUser ModeratorsvExpert

            Since this seems to work from a plain PS session, I would rather suspect an issue in the Sapien app.

            Did you check the forums over there?

            • 3. Re:PowerCLI - New-TAG hangs in a script
              gertvangorp Enthusiast
              vExpert

              Hi Luc,

               

              I have not found anything on the SAPIEN. posted the question there.

               

              Weird, if I run the powershell script outside sapien (the form project) then the script hangs on the same funtion.

               

              gert

              • 4. Re:PowerCLI - New-TAG hangs in a script
                LucD Guru
                User ModeratorsCommunity WarriorsvExpert

                It hangs as well?

                I thought you said earlier that it works outside the Sapien form?

                • 5. Re:PowerCLI - New-TAG hangs in a script
                  gertvangorp Enthusiast
                  vExpert

                  Hi LUC

                   

                  if I open a powershell window.

                   

                       connect manual to the vcenter

                       then add manual a tag using the new-tag cmdlet,

                  then everything succeeds

                   

                  I have a project in SAPIEN, exeuting / debugging this in the SAPIEN posershell program, the new-tag cmdlet does not finish.

                   

                  if I run the powershell script created in sapien, from a powershell window (no SAPIEN IDE) the cmdlet does not finish..

                   

                  Gert

                  • 6. Re:PowerCLI - New-TAG hangs in a script
                    LucD Guru
                    vExpertUser ModeratorsCommunity Warriors

                    There were some Tag related issues in earlier PowerCLI builds.

                     

                    Some actions that solved those for a number of users

                    • make sure to ignore certificate warnings (Set-PowerCLIConfiguration)
                    • connect to the vCenter with the FQDN
                    • stop/start your PowerShell session
                    • restart the Inventory service
                    • restart the VCSA
                    • 7. Re:PowerCLI - New-TAG hangs in a script
                      gertvangorp Enthusiast
                      vExpert

                      Hi Luc,

                       

                      updated the vCenter to the latest version (there is a update released today, rebooted the vCenter server (is an embedded appliance environment)

                       

                      executed  set-PowerCLIConfiguration -InvalidCertificationAction Ignore

                       

                      rebooted the machine with the SAPIEN app installed.

                       

                      still same issue.

                       

                      gert

                      • 8. Re:PowerCLI - New-TAG hangs in a script
                        LucD Guru
                        Community WarriorsvExpertUser Moderators

                        Can you share that script generated in Sapien?

                        I would like to see if I get the same behaviour in my lab.

                        • 9. Re:PowerCLI - New-TAG hangs in a script
                          gertvangorp Enthusiast
                          vExpert

                          Hi Luc,

                           

                          thanks already for looking in to this.

                           

                          Put both files need to be in same folder.

                          the properties file can be used to prefill some stuff in the form.

                           

                          in the phc file search for lucd

                           

                          other comments on the script are welcome as well, first big powershell sript..

                           

                          gert

                          • 10. Re:PowerCLI - New-TAG hangs in a script
                            LucD Guru
                            Community WarriorsvExpertUser Moderators

                            Ok, got i running to an extent (I'm obviously missing some of the expected objects).

                             

                            How did you create the TagCategory class? Cardinality, EntityType...

                            Can you do a Get-TagCategory -Name class

                             

                            Are you sure that there is something in the variable $paramClassName when you enter the function CreateClass?

                            Perhaps you could some Write-Verbose lines at the start of the function.

                             

                            Did you do a run with $verbosePreference = 'Continue' before the run?

                            Would be interesting to see the verbose output around the point where the issue is occurring.

                            • 11. Re:PowerCLI - New-TAG hangs in a script
                              gertvangorp Enthusiast
                              vExpert

                              Hi Luc

                               

                              the Class Tag Category

                              Cardinality : Single

                              EntityType  : {All}

                              Id          : urn:vmomi:InventoryServiceCategory:21486efa-028b-4589-a835-c4561275d70a:GLOBAL

                              Name        : Class

                              Uid         : /VIServer=vsphere.local\administrator@192.168.3.3:443/TagCategory=urn:vmomi:InventoryServiceCategory:2148

                                            6efa-028b-4589-a835-c4561275d70a:GLOBAL/

                              Client      : VMware.VimAutomation.ViCore.Impl.V1.VimClient

                               

                              the parameter $paramClassName as the correct value.

                               

                              The tag is created in the class category.

                               

                              verbose output

                               

                               

                              VERBOSE: Start monitoring

                              VERBOSE: 08/01/2018 22:19:45 Get-Tag Started execution

                              VERBOSE: 08/01/2018 22:19:45 Get-Tag Finished execution

                              ERROR: Get-Tag : 08/01/2018 22:19:45 Get-Tag Tag with name 'ECCS-CLASSROOM-1234-GERT-1' was not found using the specified filter(s).

                              Globals.ps1 (370, 13): ERROR: At Line: 370 char: 13

                              ERROR: +         $TagInfo = Get-Tag -Name $paramClassName

                              ERROR: +                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                              ERROR:     + CategoryInfo          : ObjectNotFound: (:) [Get-Tag], VimException

                              ERROR:     + FullyQualifiedErrorId : Core_OutputHelper_WriteNotFoundError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Tagging.GetTag

                              ERROR:

                              VERBOSE: 08/01/2018 22:19:45 Get-TagCategory Started execution

                              VERBOSE: 08/01/2018 22:19:45 New-Tag Started execution

                              VERBOSE: Create tag 'ECCS-CLASSROOM-1234-GERT-1' in category 'Class'

                               

                               

                              and there stops the script.   The get-tag dilivers an error because I do a test to see if it exists.

                              gert

                              • 12. Re:PowerCLI - New-TAG hangs in a script
                                LucD Guru
                                vExpertCommunity WarriorsUser Moderators

                                Ok, at least that confirms that the New-Tag cmdlet seems to be hanging.

                                No clue what is happening here I'm afraid.

                                 

                                One final action you could take, before opening a SR on this.

                                Try to uninstall/install PowerCLI, or even better, try to run the script from another station that has PowerCLI freshly installed.

                                • 13. Re:PowerCLI - New-TAG hangs in a script
                                  gertvangorp Enthusiast
                                  vExpert

                                  Hi Luc,

                                   

                                  tried it on another machine with same result.

                                  also on a new W10 machine fresh installed I have the same issue...

                                  will open a SR

                                  gert

                                  • 14. Re:PowerCLI - New-TAG hangs in a script
                                    LucD Guru
                                    User ModeratorsCommunity WarriorsvExpert

                                    In parallel you could have a go at the rCIsTag module.

                                    It uses the REST API.