Skip to content

Set-NBQueryOption

SYNOPSIS

Sets the behaviour of query parameters.

SYNTAX

IgnoreCase (Default)

Set-NBQueryOption [-IgnoreCase] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]

MatchMode

Set-NBQueryOption -MatchMode <String> [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm]
 [<CommonParameters>]

Pagination

Set-NBQueryOption -Pagination <String> [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm]
 [<CommonParameters>]

TagMatch

Set-NBQueryOption -TagMatch <String> [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm]
 [<CommonParameters>]

OptimisticConcurrency

Set-NBQueryOption [-OptimisticConcurrency] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm]
 [<CommonParameters>]

DESCRIPTION

Sets the behaviour of query parameters (see notes).

EXAMPLES

EXAMPLE 1

Set-NBQueryOption -IgnoreCase
Sets the Netbox API query parameters to be case-insensitive.

EXAMPLE 2

Set-NBQueryOption -IgnoreCase:$false
Sets the Netbox API query parameters to be case-sensitive (default on startup of the module).

EXAMPLE 3

Set-NBQueryOption -MatchMode 'Wildcard'
Sets the Netbox API query parameters to be treated as Powershell wildcards.

EXAMPLE 4

Set-NBQueryOption -Pagination Cursor
Get-NBIPAMAddress -All
Walks the whole IP address table with cursor pagination (Netbox 4.6+).

EXAMPLE 5

Set-NBQueryOption -TagMatch Any
Get-NBDCIMDevice -Tag 'edge', 'core'
Returns devices tagged 'edge' OR 'core' (Netbox 4.6.6+); with the default 'All' both tags are required.

EXAMPLE 6

Set-NBQueryOption -OptimisticConcurrency
$dev = Get-NBDCIMDevice -Id 42
Set-NBDCIMDevice -Id 42 -Description 'changed'
The PATCH carries If-Match with the ETag from the GET; it fails with HTTP 412 if someone else changed device 42 in between.

PARAMETERS

-IgnoreCase

If set, query parameters of type string will be case-insensitive (Netbox's `__ie`). To reset to case-sensitive, use `-IgnoreCase:$false`.

Type: SwitchParameter
Parameter Sets: IgnoreCase
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-MatchMode

Sets the match mode for query parameters. Valid values are: - Exact: Only exact matches will be returned (default). - Wildcard: Query parameters will be treated as Powershell wildcards. - Regex: Query parameters will be treated as regular expressions (Netbox's `regex`).

Type: String
Parameter Sets: MatchMode
Aliases:

Required: True
Position: Named
Default value: Exact
Accept pipeline input: False
Accept wildcard characters: False

-Pagination

How -All walks large result sets. 'Offset' (default) uses limit/offset pages exactly as before. 'Cursor' uses Netbox 4.6+ cursor pagination (?start=\<pk>, results ordered by primary key), which stays fast on very large tables where offset paging degrades. Requires Netbox 4.6+; on older servers offset paging is used automatically. Explicit -Offset on a Get cmdlet always wins.

Type: String
Parameter Sets: Pagination
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-TagMatch

How multiple values of a -Tag / -Tag_Id filter combine. 'All' (default) is Netbox's native behaviour: an object must carry every listed tag. 'Any' sends Netbox 4.6.6+ 'tag__any' / 'tag_id__any' so an object matches when it carries at least one of them. Below Netbox 4.6.6 the option is ignored (plain 'tag' is sent) because an unknown lookup would silently return every object.

Type: String
Parameter Sets: TagMatch
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-OptimisticConcurrency

Netbox 4.6+ returns an ETag on single-object GETs and honours If-Match on PATCH/PUT/DELETE (HTTP 412 when the object changed in between). When enabled, the module remembers the ETag of every object it reads and sends it as If-Match on the next update or delete of that same object, so concurrent edits fail loudly instead of silently overwriting each other. Needs PowerShell 7+ (response headers are not exposed on Windows PowerShell 5.1). Use -OptimisticConcurrency:$false to disable; disabling also clears the cached ETags.

Type: SwitchParameter
Parameter Sets: OptimisticConcurrency
Aliases:

Required: True
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ProgressAction

{{ Fill ProgressAction Description }}

Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

System.Boolean

System.String

NOTES

Depending on the API version, different sets of parameters are supported as case-insensitive. As this feature is relying on the API version and its supported parameters, not all parameters are supported as case-insensitive.

Common parameters

common request params

https://netbox.readthedocs.io/en/stable/rest-api/overview/