PowerCLI

 View Only
  • 1.  NSX-T IPSET Tags

    Posted Jan 11, 2021 09:59 PM

    I'm having issue creating an IPSET with PowerCLI and assigning a new tag to it....

    I get this error when I add this line to my code:  $ipsetspec.tags = $ipsettags

    userValue
    At line:1 char:1
    + $ipsetsvc.create($ipsetspec)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : OperationStopped: (:) [], CisException
    + FullyQualifiedErrorId : VMware.VimAutomation.Cis.Core.Types.V1.CisException

     

    My code:

    #################### NSX Groups ####################
    #Create IPSET - Demo - DemoName
    #Variables
    $ipsetname = "Demo - $DemoName - Physical Network"
    $ipsetips = "172.21.$Network.0/24"
    $ipsettags = "test"
    #Create IP Set
    $ipsetsvc = Get-NsxtService -Name com.vmware.nsx.ip_sets
    $ipsetspec = $ipsetsvc.Help.create.ip_set.Create()
    $ipsetspec.ip_addresses = New-Object System.Collections.Generic.List[string]
    $ipsetspec.display_name = $ipsetname
    $ipsetspec.description = $description
    $ipsetspec.revision = 1
    $ipsetspec.tags = $ipsettags
    $ipsetips.Split(",") | ForEach { $ipsetspec.ip_addresses.Add($_) }
    $ipsetsvc.create($ipsetspec)
     
    Thanks for any advice!
    Version 3.1 of NSX-T


  • 2.  RE: NSX-T IPSET Tags

    Posted Jan 12, 2021 07:25 AM

    The tags property is a hash table, not a string.
    That hash table has 2 properties: scope and tag.

    See also NSX-T Data Center REST API - VMware API Explorer - VMware {code}