DCIM Examples
Examples for Data Center Infrastructure Management (DCIM) operations.
Sites
List All Sites
powershell
Get-NBDCIMSite
Create a Site
powershell
New-NBDCIMSite -Name 'Amsterdam DC' -Slug 'amsterdam-dc' -Status 'active'
Update a Site
powershell
Set-NBDCIMSite -Id 1 -Description 'Primary datacenter in Amsterdam'
Devices
List All Devices
powershell
Get-NBDCIMDevice
Get Device by Name
powershell
Get-NBDCIMDevice -Name 'server01'
Get Devices by Site
powershell
Get-NBDCIMDevice -Site 1
Get Active Devices
powershell
Get-NBDCIMDevice -Status 'active'
Create a Device
powershell
$params = @{
Name = 'server01'
Device_Type = 1 # Device type ID
Site = 1 # Site ID
Role = 1 # Device role ID
Status = 'active'
}
New-NBDCIMDevice @params
Update Device Status
powershell
Set-NBDCIMDevice -Id 1 -Status 'offline'
Delete a Device
powershell
Remove-NBDCIMDevice -Id 1 -Confirm
Interfaces
Get Device Interfaces
powershell
Get-NBDCIMInterface -Device_Id 1
Create an Interface
powershell
New-NBDCIMInterface -Name 'eth0' -Device 1 -Type '1000base-t'
Update Interface
powershell
Set-NBDCIMInterface -Id 1 -Enabled $true -Description 'Management interface'
Racks
List Racks in a Site
powershell
Get-NBDCIMRack -Site 1
Create a Rack
powershell
New-NBDCIMRack -Name 'Rack-A01' -Site 1 -U_Height 42 -Status 'active'
Get Rack with Devices
powershell
$rack = Get-NBDCIMRack -Id 1
Get-NBDCIMDevice -Rack $rack.id
Rack Elevation
PowerNetbox provides functions to visualize rack elevations in various formats.
Get Rack Elevation Data
```powershell
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 Native SVG Rendering
```powershell
Get Netbox's native SVG rendering
$svg = Get-NBDCIMRackElevation -Id 24 -Render svg
Save SVG to file
$svg | Out-File -Path './rack.svg' ```
Export to Console (ASCII Art)
```powershell
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 -Compact ```
Example 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
Export to HTML
```powershell
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 ```
Export to Markdown
```powershell
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 ```
Export to SVG
```powershell
Use Netbox's native SVG renderer
Export-NBRackElevation -Id 24 -Format SVG -Path './rack.svg' ```
Batch Export All Racks
```powershell
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 Support
```powershell
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 ```
Parameters Reference
| 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 |
Cables
List All Cables
powershell
Get-NBDCIMCable
Create a Cable
powershell
$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 @params
Locations & Regions
Create a Region
powershell
New-NBDCIMRegion -Name 'Europe' -Slug 'europe'
Create a Location
powershell
New-NBDCIMLocation -Name 'Floor 1' -Slug 'floor-1' -Site 1
Manufacturers & Device Types
List Manufacturers
powershell
Get-NBDCIMManufacturer
Create a Manufacturer
powershell
New-NBDCIMManufacturer -Name 'Dell' -Slug 'dell'
List Device Types
powershell
Get-NBDCIMDeviceType
Get Device Types by Manufacturer
powershell
Get-NBDCIMDeviceType -Manufacturer 1
Platforms
List Platforms
powershell
Get-NBDCIMPlatform
Create a Platform
powershell
New-NBDCIMPlatform -Name 'Ubuntu 22.04' -Slug 'ubuntu-22-04'
Bulk Operations
Export All Devices to CSV
powershell
Get-NBDCIMDevice |
Select-Object name, @{N='site';E={$_.site.name}}, status, serial |
Export-Csv -Path 'devices.csv' -NoTypeInformation
Update Multiple Devices
```powershell
Set all devices in site to maintenance
Get-NBDCIMDevice -Site 1 | ForEach-Object { Set-NBDCIMDevice -Id $_.id -Status 'planned' } ```
Count Devices per Site
powershell
Get-NBDCIMDevice |
Group-Object { $_.site.name } |
Select-Object Name, Count |
Sort-Object Count -Descending