Skip to content

ConvertToNBTagReference

Since

v4.7.0.1

SYNOPSIS

Normalises a -Tags / -Add / -Remove value into what the Netbox API accepts for tag references.

SYNTAX

ConvertToNBTagReference [[-Tags] <Object[]>] [-ProgressAction <ActionPreference>] [<CommonParameters>]

DESCRIPTION

Netbox resolves related objects in a request body only from a numeric ID or from a dictionary of attributes; a bare tag name string is rejected with "Related objects must be referenced by numeric ID or by dictionary of attributes". This helper turns numeric strings into IDs and other strings into @{ name = '\<tag>' }, and passes hashtables / objects (already attribute dictionaries) through unchanged, so every cmdlet that documents "tag names or IDs" really accepts both.

EXAMPLES

EXAMPLE 1

ConvertToNBTagReference -Tags 'web', 12, @{ slug = 'prod' }
# -> @{ name = 'web' }, 12, @{ slug = 'prod' }

PARAMETERS

-Tags

The raw values as bound to the cmdlet parameter.

Type: Object[]
Parameter Sets: (All)
Aliases:

Required: False
Position: 1
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

[object[]] Tag references safe to serialise into the request body.

NOTES

AddedInVersion: v4.7.0.1 Internal helper (not exported in production builds).

Common parameters

common request params