Automation

 View Only
  • 1.  Duplicate elements when running script multiple times

    Posted Mar 26, 2024 09:17 AM

    Hi all

    I created a script to configure a vlan bridge on a segment. But when I run the script multiple times, my variables $segment , $bridgeProflie, $vlanTz become arrays with duplicate elements.

    When I disconnect and reconnect my session, it will work again for one run.

    Obviously I can work around this but I would like to understand why this is happening.

     

    First run:

    PS /Users/filipsmeets/repos> $segment.GetType() | Fl Basetype

    BaseType : VMware.Bindings.Nsx.Policy.Model.PolicyConfigResource

    Second run:

    PS /Users/filipsmeets/repos> $segment.GetType() | Fl Basetype

    BaseType : System.Array

    Duplicate entries in the Array after second run:

    S /Users/filipsmeets/repos> $segment |fl DisplayName

    DisplayName : example-segment

    DisplayName : example-segment



  • 2.  RE: Duplicate elements when running script multiple times

    Posted Mar 26, 2024 09:44 AM

    These functions are generated from the OpenAPI files, and this definitely looks like a bug.
    I suggest opening an SR.

    If GSS claims that PowerCLI is not supported or that you need a Developer Support contract, point them to the PowerCLI support policy: https://developer.vmware.com/docs/15315/GUID-0F835722-E667-4177-A8EF-51AB15FA837E.html.




  • 3.  RE: Duplicate elements when running script multiple times

    Posted 30 days ago

    Thx for the reply Luc. As mentioned I have built in a workarround to mitigate this.