Skip to content

Test-NBDeprecatedParameter

Since

v4.5.0.0

SYNOPSIS

Checks if a deprecated parameter is being used and handles it appropriately.

SYNTAX

Test-NBDeprecatedParameter [-ParameterName] <String> [-DeprecatedInVersion] <String> [-BoundParameters] <Hashtable> [[-ReplacementMessage] <String>] [-ProgressAction <ActionPreference>] [<CommonParameters>]

DESCRIPTION

This helper function checks if a deprecated parameter is being used and: - Emits a warning if the current Netbox version is >= the deprecation version - Returns $true if the parameter should be excluded from the API request - Returns $false if the parameter should still be sent (older Netbox version)

This allows for graceful deprecation of parameters while maintaining backwards compatibility with older Netbox versions.

EXAMPLES

EXAMPLE 1

```

In a function with deprecated Is_Staff parameter:

if (Test-NBDeprecatedParameter -ParameterName 'Is_Staff' -DeprecatedInVersion '4.5.0' -BoundParameters $PSBoundParameters) { $PSBoundParameters.Remove('Is_Staff') | Out-Null } ```

PARAMETERS

-ParameterName

The name of the deprecated parameter.

```yaml Type: String Parameter Sets: (All) Aliases:

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

-DeprecatedInVersion

The Netbox version where this parameter was deprecated/removed.

```yaml Type: String Parameter Sets: (All) Aliases:

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

-BoundParameters

The $PSBoundParameters from the calling function.

```yaml Type: Hashtable Parameter Sets: (All) Aliases:

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

-ReplacementMessage

Optional message explaining what to use instead.

```yaml Type: String Parameter Sets: (All) Aliases:

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

-ProgressAction

{{ Fill ProgressAction Description }}

```yaml 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

[bool] - $true if parameter should be excluded, $false if it should be included

NOTES

AddedInVersion: v4.5.0.0 This function requires that Connect-NBAPI has been called and $script:NetboxConfig.ParsedVersion is set.

Common parameters

common request params