VMware Cloud Community
KAhnemann
Contributor
Contributor

NSX-T IPSET Tags

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
0 Kudos
1 Reply
LucD
Leadership
Leadership

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}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos