Skip to content

Test-NBAuthentication

Since

v4.5.0.0

SYNOPSIS

Tests the current Netbox API authentication.

SYNTAX

Test-NBAuthentication [-Detailed] [-Raw] [-ProgressAction <ActionPreference>] [<CommonParameters>]

DESCRIPTION

Validates the current API token by calling the authentication-check endpoint. On Netbox 4.5+, uses the native /api/authentication-check/ endpoint. On older versions, falls back to calling Get-NBVersion as an authenticated check.

Returns $true if authenticated, $false otherwise. Use -Detailed to get full user information (4.5+) or error details.

EXAMPLES

EXAMPLE 1

Test-NBAuthentication

Returns $true if the current token is valid, $false otherwise.

EXAMPLE 2

Test-NBAuthentication -Detailed

Returns the authenticated user object on Netbox 4.5+, or error details if authentication fails.

EXAMPLE 3

if (Test-NBAuthentication) { # Token is valid, proceed with operations Get-NBDCIMDevice -All }

PARAMETERS

-Detailed

Return detailed information instead of just $true/$false. On Netbox 4.5+: Returns the authenticated user object. On older versions or errors: Returns a PSCustomObject with Authenticated and Error properties.

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

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

-Raw

Return the raw API response (only applies when -Detailed is used).

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

Required: False Position: Named Default value: False 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] When called without -Detailed

[PSCustomObject] When called with -Detailed

NOTES

AddedInVersion: v4.5.0.0

Common parameters

common request params

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