Examples for Data Center Infrastructure Management (DCIM) operations.
Get-NBDCIMSiteNew-NBDCIMSite -Name 'Amsterdam DC' -Slug 'amsterdam-dc' -Status 'active'Set-NBDCIMSite -Id 1 -Description 'Primary datacenter in Amsterdam'Get-NBDCIMDeviceGet-NBDCIMDevice -Name 'server01'Get-NBDCIMDevice -Site 1Get-NBDCIMDevice -Status 'active'$params = @{
Name = 'server01'
Device_Type = 1 # Device type ID
Site = 1 # Site ID
Role = 1 # Device role ID
Status = 'active'
}
New-NBDCIMDevice @paramsSet-NBDCIMDevice -Id 1 -Status 'offline'Remove-NBDCIMDevice -Id 1 -ConfirmGet-NBDCIMInterface -Device_Id 1New-NBDCIMInterface -Name 'eth0' -Device 1 -Type '1000base-t'Set-NBDCIMInterface -Id 1 -Enabled $true -Description 'Management interface'Get-NBDCIMRack -Site 1New-NBDCIMRack -Name 'Rack-A01' -Site 1 -U_Height 42 -Status 'active'$rack = Get-NBDCIMRack -Id 1
Get-NBDCIMDevice -Rack $rack.idPowerNetbox provides functions to visualize rack elevations in various formats.
# Get elevation data for a rack (JSON)
Get-NBDCIMRackElevation -Id 24
# Get rear face elevation
Get-NBDCIMRackElevation -Id 24 -Face rear
# Get all elevation units (auto-pagination)
Get-NBDCIMRackElevation -Id 24 -All
# Get only occupied units
Get-NBDCIMRackElevation -Id 24 -All | Where-Object { $_.device }# Get Netbox's native SVG rendering
$svg = Get-NBDCIMRackElevation -Id 24 -Render svg
# Save SVG to file
$svg | Out-File -Path './rack.svg'# Display rack elevation in terminal with colors
Export-NBRackElevation -Id 24 -Format Console
# Compact view (hides empty slots)
Export-NBRackElevation -Id 24 -Format Console -Compact
# Without ANSI colors (for logging/piping)
Export-NBRackElevation -Id 24 -Format Console -NoColor
# Show both front and rear faces
Export-NBRackElevation -Id 24 -Format Console -Face Both -CompactExample console output:
╔═════════════════════════════════════════════════════════╗
║ Amsterdam-R01 - Front Face ║
║ Site: Amsterdam DC | Height: 42U ║
╠════╦════════════════════════════════════════════════════╣
║ ║ ... (40 empty slots) ... ║
║ 2 ║ switch-01 ║
║ 1 ║ firewall-01 ║
╚════╩════════════════════════════════════════════════════╝
Generated by PowerNetbox | 2026-01-02 09:00
# Generate HTML and save to file
Export-NBRackElevation -Id 24 -Format HTML -Path './rack.html'
# Generate HTML with native Netbox SVG
Export-NBRackElevation -Id 24 -Format HTML -UseNativeRenderer -Path './rack.html'
# Get HTML as string
$html = Export-NBRackElevation -Id 24 -Format HTML# Generate GitHub-flavored Markdown
Export-NBRackElevation -Id 24 -Format Markdown
# Save to file
Export-NBRackElevation -Id 24 -Format Markdown -Path './rack.md'
# Include all empty slots in table
Export-NBRackElevation -Id 24 -Format Markdown -IncludeEmptySlots# Use Netbox's native SVG renderer
Export-NBRackElevation -Id 24 -Format SVG -Path './rack.svg'# Export all racks in a site to HTML files
$outputDir = './rack-reports'
New-Item -ItemType Directory -Path $outputDir -Force
Get-NBDCIMRack -Site 1 | Export-NBRackElevation -Format HTML -Path $outputDir
# Export all racks as Markdown
Get-NBDCIMRack | ForEach-Object {
$filename = "./racks/$($_.name -replace '[^\w\-]', '_').md"
Export-NBRackElevation -Id $_.id -Format Markdown -Path $filename -Force
}# Pipeline from Get-NBDCIMRack
Get-NBDCIMRack -Name 'Rack-A01' | Export-NBRackElevation -Format Console
# Export multiple racks
Get-NBDCIMRack -Site 1 | Export-NBRackElevation -Format HTML -Path './racks/' -Force| Parameter | Description |
|---|---|
-Id |
Rack ID (required, accepts pipeline) |
-Format |
Output format: HTML, Markdown, SVG, Console (default: HTML) |
-Face |
Rack face: Front, Rear, Both (default: Front) |
-Path |
Output file path or directory |
-UseNativeRenderer |
Use Netbox's built-in SVG renderer |
-IncludeEmptySlots |
Include empty rack units in output |
-Compact |
Console only: hide empty slots, show summary |
-NoColor |
Console only: disable ANSI color codes |
-PassThru |
Return content even when writing to file |
-Force |
Overwrite existing files |
Get-NBDCIMCable$params = @{
A_Terminations = @(@{object_type = 'dcim.interface'; object_id = 1})
B_Terminations = @(@{object_type = 'dcim.interface'; object_id = 2})
Type = 'cat6'
Status = 'connected'
}
New-NBDCIMCable @paramsNew-NBDCIMRegion -Name 'Europe' -Slug 'europe'New-NBDCIMLocation -Name 'Floor 1' -Slug 'floor-1' -Site 1Get-NBDCIMManufacturerNew-NBDCIMManufacturer -Name 'Dell' -Slug 'dell'Get-NBDCIMDeviceTypeGet-NBDCIMDeviceType -Manufacturer 1Get-NBDCIMPlatformNew-NBDCIMPlatform -Name 'Ubuntu 22.04' -Slug 'ubuntu-22-04'Get-NBDCIMDevice |
Select-Object name, @{N='site';E={$_.site.name}}, status, serial |
Export-Csv -Path 'devices.csv' -NoTypeInformation# Set all devices in site to maintenance
Get-NBDCIMDevice -Site 1 | ForEach-Object {
Set-NBDCIMDevice -Id $_.id -Status 'planned'
}Get-NBDCIMDevice |
Group-Object { $_.site.name } |
Select-Object Name, Count |
Sort-Object Count -Descending