Test-NBMinimumVersion
Since
v4.5.0.0
SYNOPSIS
Checks if the connected Netbox version meets the minimum requirement.
SYNTAX
Test-NBMinimumVersion [-ParameterName] <String> [-MinimumVersion] <String> [-BoundParameters] <Hashtable>
[[-FeatureName] <String>] [-ProgressAction <ActionPreference>] [<CommonParameters>]
DESCRIPTION
This helper function checks if a parameter requires a minimum Netbox version and handles it appropriately: - Emits a warning if the current Netbox version is \< the required version - Returns $true if the parameter should be excluded from the API request - Returns $false if the parameter can be used (version meets requirement)
This allows for graceful handling of new features that only work on newer Netbox versions while maintaining backwards compatibility.
EXAMPLES
EXAMPLE 1
# In a function with a Profile parameter that requires Netbox 4.5+:
if (Test-NBMinimumVersion -ParameterName 'Profile' -MinimumVersion '4.5.0' -BoundParameters $PSBoundParameters) {
# Version too low - parameter will be excluded
}
PARAMETERS
-ParameterName
The name of the parameter that requires a minimum version.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-MinimumVersion
The minimum Netbox version required for this parameter.
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.
Type: Hashtable
Parameter Sets: (All)
Aliases:
Required: True
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-FeatureName
Optional friendly name for the feature (used in warning message).
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 }}
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 (version too low), $false if it can be used
NOTES
AddedInVersion: v4.5.0.0 This function requires that Connect-NBAPI has been called and $script:NetboxConfig.ParsedVersion is set.