7 Replies Latest reply on Jan 24, 2019 2:22 AM by bryanvaneeden

    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