I am trying to update a nsgroup to be a list of IP sets using the NSX-T api/powershell. Here is what I have:
$nsgroupsvc = Get-NsxtService -Name com.vmware.nsx.ns_groups
$nsgroups = $nsgroupsvc.list()
$nsgroup = $nsgroups.results | Where-Object {$_.display_name -eq $groupname}
$nsgroupspec = $nsgroupsvc.Help.create.ns_group.Create()
$ipSetId = "000acca4-2c15-447c-9218-dc39d5d7249c"
$nsgroupmemberspec = $nsgroupsvc.Help.create.ns_group.members.Element.Create()
$nsgroupmemberspec.target_property = "id"
$nsgroupmemberspec.op = "EQUALS"
$nsgroupmemberspec.value = $ipSetId
$nsgroupmemberspec.target_type = "IPSET"
$nsgroupspec.members.Add($nsgroupmemberspec)
$nsgroupsvc.update($nsgroup.id, $nsgroupspec)
but the error I get when updating it is:
"System.Management.Automation.CmdletInvocationException: The scope number '2' exceeds the number of active scopes.
Parameter name: scopeID
Actual value was 2. ---> System.Management.Automation.PSArgumentOutOfRangeException: The scope number '2' exceeds the number of active scopes.
Parameter name: scopeID
Actual value was 2.
at System.Management.Automation.SessionStateInternal.GetScopeByID(Int32 scopeID)
at System.Management.Automation.SessionStateInternal.GetScopeByID(String scopeID)
at System.Management.Automation.SessionStateInternal.GetVariableTableAtScope(String scopeID)
at Microsoft.PowerShell.Commands.VariableCommandBase.GetMatchingVariables(String name, String lookupScope, Boolean& wasFiltered, Boolean quiet)
at Microsoft.PowerShell.Commands.GetVariableCommand.ProcessRecord()
at System.Management.Automation.Cmdlet.DoProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
--- End of inner exception stack trace ---
at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.CoreInvoke[TOutput](IEnumerable input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.Invoke[T](IEnumerable input, IList`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.InvokeWithDebugger(IEnumerable`1 input, IList`1 output, PSInvocationSettings settings, Boolean invokeMustRun)
at System.Management.Automation.ScriptDebugger.ProcessCommand(PSCommand command, PSDataCollection`1 output)
at Microsoft.PowerShell.EditorServices.Session.PowerShell4Operations.ExecuteCommandInDebugger[TResult](PowerShellContext powerShellContext, Runspace currentRunspace, PSCommand psCommand, Boolean sendOutputToHost, Nullable`1& debuggerResumeAction)
at Microsoft.PowerShell.EditorServices.PowerShellContext.ExecuteCommandInDebugger[TResult](PSCommand psCommand, Boolean sendOutputToHost)
at Microsoft.PowerShell.EditorServices.PowerShellContext.<ExecuteCommand>d__48`1.MoveNext()"
which means nothing to me.
I am working off an example from RvdNieuwendijk
Ideas anyone?