Common issues and their solutions.
Cause: Network connectivity or hostname issue.
Solution:
# Test connectivity
Test-NetConnection -ComputerName 'netbox.example.com' -Port 443
# Verify hostname resolves
Resolve-DnsName 'netbox.example.com'Cause: Self-signed or invalid certificate.
Solution:
# Skip certificate validation
Connect-NBAPI -Hostname 'netbox.local' -Credential $cred -SkipCertificateCheckCause: Invalid or expired API token.
Solution:
- Verify your token in Netbox UI (Admin → API Tokens)
- Check token hasn't expired
- Ensure token has required permissions
# Verify token format
$cred = [PSCredential]::new('api', (ConvertTo-SecureString 'your-token-here' -AsPlainText -Force))
Connect-NBAPI -Hostname 'netbox.example.com' -Credential $credCause: Token lacks permissions for the requested operation.
Solution:
- Check token permissions in Netbox UI
- Ensure token allows the action (read/write/delete)
- For write operations, token needs write permission
Symptom: Import-Module PowerNetbox fails.
Solution:
# Check if module is installed
Get-Module PowerNetbox -ListAvailable
# Reinstall if needed
Install-Module PowerNetbox -Force -Scope CurrentUser
# Clear module cache and reimport
Remove-Module PowerNetbox -Force -ErrorAction SilentlyContinue
Import-Module PowerNetbox -ForceSymptom: Get-NBDCIMDevice: The term is not recognized...
Solution:
# Ensure module is imported
Import-Module PowerNetbox
# Verify functions are exported
Get-Command -Module PowerNetbox | Measure-Object
# Should show 478 commandsCause: Invalid parameter or missing required field.
Solution:
# Check required parameters
Get-Help New-NBDCIMDevice -Parameter *
# Example: Device requires name, device_type, and site
New-NBDCIMDevice -Name 'server01' -Device_Type 1 -Site 1Cause: Resource doesn't exist or wrong ID.
Solution:
# Verify resource exists
Get-NBDCIMDevice -Id 123
# Check if using correct ID type
Get-NBDCIMDevice -Name 'server01' # By name
Get-NBDCIMDevice -Id 1 # By ID (integer)Cause: Duplicate entry or constraint violation.
Solution:
# Check for existing resource
Get-NBDCIMDevice -Name 'server01'
# Use Set- to update instead of New- to create
Set-NBDCIMDevice -Id $existingDevice.id -Description 'Updated'Symptom: Errors on Windows PowerShell 5.1.
Solution:
# Check version
$PSVersionTable.PSVersion
# PowerNetbox supports 5.1+, but 7+ is recommended
# Install PowerShell 7 for best experience
winget install Microsoft.PowerShellCause: Older TLS version.
Solution:
# Force TLS 1.2 (run before Connect-NBAPI)
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12Cause: Retrieving too many objects.
Solution:
# Use -Limit to reduce results
Get-NBDCIMDevice -Limit 50
# Use filters to narrow results
Get-NBDCIMDevice -Site 1 -Status 'active'Cause: Large result sets or slow network.
Solution:
# Use pagination
$offset = 0
$limit = 100
do {
$devices = Get-NBDCIMDevice -Limit $limit -Offset $offset
# Process devices...
$offset += $limit
} while ($devices.Count -eq $limit)Get-NBDCIMDevice -Verbose# Use -Raw to see unprocessed API response
Get-NBDCIMDevice -Id 1 -Raw | ConvertTo-Json -Depth 10If you encounter a bug, please report it:
Include:
- PowerShell version (
$PSVersionTable) - Module version (
Get-Module PowerNetbox) - Netbox version
- Error message (use
-Verbose) - Steps to reproduce