5 Replies Latest reply on Dec 7, 2018 11:51 AM by kwhornlcs

    New-TagAssignment          Value cannot be null.

    gjbrown Novice

      trying to run the following script and getting errors

      Script

       

      $VMList = Import-CSV -Path C:\vmw_scripts\test.csv

      $vcenter = "myvcenter"

       

      connect-viserver $vcenter

      foreach ($vm in $VMList)

      {

      Get-VM $vm.vm | New-TagAssignment -Tag $vm.tag

      }

       

      error

      At C:\vmw_scripts\set-tag.ps1:8 char:17

      + Get-VM $vm.vm | New-TagAssignment -Tag $vm.tag

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

          + CategoryInfo          : NotSpecified: (:) [New-TagAssignment], VimException

          + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Tagging.NewTagAssignment

       

      New-TagAssignment : 3/10/2018 3:48:59 PM New-TagAssignment Value cannot be null.

      Parameter name: collection

      At C:\vmw_scripts\set-tag.ps1:8 char:17

      + Get-VM $vm.vm | New-TagAssignment -Tag $vm.tag

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

          + CategoryInfo          : NotSpecified: (:) [New-TagAssignment], VimException

          + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Tagging.NewTagAssignment

       

      New-TagAssignment : 3/10/2018 3:49:00 PM New-TagAssignment Value cannot be null.

      Parameter name: collection

      At C:\vmw_scripts\set-tag.ps1:8 char:17

      + Get-VM $vm.vm | New-TagAssignment -Tag $vm.tag

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

          + CategoryInfo          : NotSpecified: (:) [New-TagAssignment], VimException

          + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Tagging.NewTagAssignment

       

      New-TagAssignment : 3/10/2018 3:49:01 PM New-TagAssignment Value cannot be null.

      Parameter name: collection

      At C:\vmw_scripts\set-tag.ps1:8 char:17

      + Get-VM $vm.vm | New-TagAssignment -Tag $vm.tag

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

          + CategoryInfo          : NotSpecified: (:) [New-TagAssignment], VimException

          + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Tagging.NewTagAssignment

       

      content of CSV

       

      vm,tag

      server1, Application_Services

      server1,Migrated

      server2, Application_Services

      server2,Migrated

       

       

      PS info

       

      PS C:\vmw_scripts> $psversiontable

       

      Name                           Value                                                                                                                                                         

      ----                           -----                                                                                                                                                         

      PSVersion                      5.1.14393.1944                                                                                                                                                

      PSEdition                      Desktop                                                                                                                                                       

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

      BuildVersion                   10.0.14393.1944                                                                                                                                               

      CLRVersion                     4.0.30319.42000                                                                                                                                               

      WSManStackVersion              3.0                                                                                                                                                           

      PSRemotingProtocolVersion      2.3                                                                                                                                                           

      SerializationVersion           1.1.0.1                                                                                                                                                       

       

      Powercli info

      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

        • 1. Re: New-TagAssignment          Value cannot be null.
          kwhornlcs Enthusiast
          vExpert

          Try this:

           

          $VMList = Import-CSV -Path C:\vmw_scripts\test.csv
          $vcenter = "myvcenter"
          
          connect-viserver $vcenter
          
          foreach ($vm in $VMList) {
               Get-Tag $vm.tag | New-TagAssignment -Entity $vm.vm
          }
          
          • 2. Re: New-TagAssignment          Value cannot be null.
            gjbrown Novice

            thanks, but this them prompts for the Tag and even after I put it in, I get further errors

             

            Supply values for the following parameters:

            Tag: Migrated

            Get-Tag : 3/11/2018 9:07:20 PM Get-Tag com.vmware.vapi.std.errors.unauthenticated {'messages':

            [com.vmware.vapi.std.localizable_message {'id': vapi.method.authentication.required, 'default_message': This method

            requires authentication., 'args': []}], 'data':}

            At C:\vmw_scripts\set-tag.ps1:9 char:1

            + Get-Tag $vm.tag | New-TagAssignment -Entity $vm.vm

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

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

                + FullyQualifiedErrorId : VMware.VimAutomation.ViCore.Impl.V1.Service.Tagging.Cis.TaggingServiceCisImpl.GetTag.Error,VM

               ware.VimAutomation.ViCore.Cmdlets.Commands.Tagging.GetTag

             

            Get-Tag : 3/11/2018 9:07:20 PM Get-Tag Tag with name 'Application_Services' was not found using the specified filter(s).

            At C:\vmw_scripts\set-tag.ps1:9 char:1

            + Get-Tag $vm.tag | New-TagAssignment -Entity $vm.vm

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

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

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

               Tag

            • 3. Re: New-TagAssignment          Value cannot be null.
              kwhornlcs Enthusiast
              vExpert

              Just curious, can you run Get-Tag alone with no errors - should produce a list of all tags in your environment.

               

              If you can, is the Application_Services tag in there and spelled the same as your input?

              • 4. Re: New-TagAssignment          Value cannot be null.
                bryanvaneeden Lurker

                We've been having the same errors for ages on all cmdlets that have anything to do with tags. Did you ever fix it? I started a case now, just want to see this fixed.

                 

                I think this started when they moved from PowerCLI 6.5 to Powershell Modules...

                • 5. Re: New-TagAssignment          Value cannot be null.
                  kwhornlcs Enthusiast
                  vExpert

                  Are you getting the error on the Get-Tag run by itself, or when it's qualified?