2 Replies Latest reply on Aug 19, 2019 9:50 PM by goce74

    Remove-CIVAppNetwork randomly fails with "The operation cannot be performed because an input object contains stale data"

    alfnav Lurker

      Hi there,


      I'm new to PowerCLI and also to PowerShell, and I think I'm missing something but I can't help to find out what is going on. I'm writing a script that takes a vAPP from a catalog which has a VM inside I can manage to add it a new network to work with but when I try to remove it fails randomly. Find below the piece of code I'm using to add the network (always work like a charm) and the piece of code to remove it (that inexplicably sometimes work and sometimes doesn't)



      # Adding the network correctly

      $myVapp = Get-CIVApp -orgvdc $orgvdc -name $vapp_New_Name

      $myOrgVdcNetwork = Get-OrgVdcNetwork -name $orgVdc_Network_Name -OrgVdc $orgVdc

      New-CIVAppNetwork -VApp $myVapp -Direct -ParentOrgVdcNetwork $myOrgVdcNetwork


      #Then I try to remove it

      $myVapp = Get-CIVApp -orgvdc $orgvdc -name $vapp_New_Name

      Get-CIVApp -Name $myVapp | Get-CIVAppNetwork | Remove-CIVAppNetwork -Confirm:$false


      Bellow is the error reported randomly:

      Get-CIVApp -Name $myVapp | Get-CIVAppNetwork | Remove-CIVAppNetwork -Confirm:$false



      Remove-CIVAppNetwork : 6/6/2019 8:15:46 PM Remove-CIVAppNetwork The operation cannot be performed because an input object contains stale data. The object named 'Public_Tenant' contains data which no longer corresponds to the the actual state of the

      server. To resolve the issue retrieve a fresh copy of the object from the server and use it to perform the operation.

      At line:2 char:48

      + ... me $myVapp | Get-CIVAppNetwork | Remove-CIVAppNetwork -Confirm:$false

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

          + CategoryInfo          : NotSpecified: (:) [Remove-CIVAppNetwork], CIException

          + FullyQualifiedErrorId : CloudImpl_VAppNetworkUpdateHelper_UpdateVAppNetworkUplinkSettings_CIError,VMware.VimAutomation.Cloud.Commands.Cmdlets.VApp.RemoveCiVAppNetwork



      Any help would be very appreciated.