{"id":32578371,"url":"https://github.com/thordreier/netboxing","last_synced_at":"2025-10-29T14:56:35.332Z","repository":{"id":174641235,"uuid":"444343090","full_name":"thordreier/NetBoxing","owner":"thordreier","description":"PowerShell module: Interact with NetBox API","archived":false,"fork":false,"pushed_at":"2025-05-07T22:08:27.000Z","size":65,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-07T23:20:26.194Z","etag":null,"topics":["dcim","ipam","netbox","powershell","powershell-module"],"latest_commit_sha":null,"homepage":"https://www.powershellgallery.com/packages/NetBoxing/","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thordreier.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-01-04T08:33:38.000Z","updated_at":"2025-05-07T22:08:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"fb87ff32-5dbe-44ee-9a5b-3c03aeb5ca00","html_url":"https://github.com/thordreier/NetBoxing","commit_stats":null,"previous_names":["thordreier/netboxing"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/thordreier/NetBoxing","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thordreier%2FNetBoxing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thordreier%2FNetBoxing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thordreier%2FNetBoxing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thordreier%2FNetBoxing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thordreier","download_url":"https://codeload.github.com/thordreier/NetBoxing/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thordreier%2FNetBoxing/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281642036,"owners_count":26536358,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-29T02:00:06.901Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dcim","ipam","netbox","powershell","powershell-module"],"created_at":"2025-10-29T14:56:27.568Z","updated_at":"2025-10-29T14:56:35.324Z","avatar_url":"https://github.com/thordreier.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NetBoxing\n\nPowerShell module: Interact with NetBox API.\n\n## Usage\n\n### Examples\n\n```powershell\n#### Connect-Netbox\n\n# Connect to Netbox\n$nbUri   = 'https://netbox.domain.tld'\n$nbToken = 'ApiKeyGoesHere'  # If \"PSVault\" module is installed, then something like this could be used:\n                             # $nbToken = (Get-VaultCredential -Name Netbox).GetNetworkCredential().Password\nConnect-Netbox -Uri $nbUri -Token $nbToken\n\n\n\n#### Invoke-NetboxRequest\n\n# Fetch all sites from NetBox\nInvoke-NetboxRequest dcim/sites/ -Follow\n\n# Fetch site with ID 1 from Netbox\nInvoke-NetboxRequest -Uri dcim/sites/1/\n\n# Create new tenant\nInvoke-NetboxRequest -Uri tenancy/tenants/ -Method Post -Body @{name='Example Tenant'; slug='example-tenant'}\n\n\n\n#### Find-NetboxObject\n\n\n# Find all prefixes attaced to VLAN 3999.\nFind-NetboxObject -Uri ipam/prefixes/ -Properties @{vlan = @{vid = 3999}}\n\n# Find all prefixes attaced to VLAN 3999. \"otherproperty\" is ignored in search.\nFind-NetboxObject -Uri ipam/prefixes/ -FindBy 'vlan.vid' -Properties @{vlan = @{vid = 3999}; otherproperty='foobar'}\n\n# Find all VLANs belonging to VLAN group \"test\".\n# Sometimes the NetBox API want queries \"different\". It's not \"?group_slug=test\" but \"?group=test\"\n# If the \"Findby\" is omitted in this example, then NetBox will return all VLAN objects back, and the filtering will be done only on client side.\n# Stuff like \"Got 18 objects back from server and returned 2\" can be seen in verbose output.\nFind-NetboxObject ipam/vlans/ -Properties @{group=@{slug='test'}} -FindBy 'group=group.slug'\n\n\n\n#### Invoke-NetboxPatch (you would often use Invoke-NetboxUpsert instead!)\n\n# Patch tenant 3 with description.\n# This is always sent to Netbox, even if description hasn't changes.\n# The function doesn't know the previous state of the properties.\nInvoke-NetboxPatch -Uri tenancy/tenants/3/ -Changes @{description = 'example'}\n\n# Fetch VLAN object with id 1 and change description.\n# If description is already correct, then a patch request isn't sent to Netbox.\n# Old versions of Netbox didn't have an \"url\" property in objects. If that's the case, then this should be added:\n# -Uri \"ipam/vlans/$($v.id)/\"\n$v = Invoke-NetboxRequest ipam/vlans/1/\nInvoke-NetboxPatch -Item $v -Changes @{description = 'example'}\n\n\n\n#### Invoke-NetboxUpsert\n\n# If prefix 10.0.0.0/30 already exist, then set description. If it doesn't exist, then create it.\nInvoke-NetboxUpsert -Uri ipam/prefixes/ -FindBy 'prefix' -Properties @{\n    prefix='10.0.0.0/30'\n    description='example'\n}\n\n# Find all prefixes attached to VLAN 3999 and show which changes that should be made (as warning).\n# Remove -NoUpdate to send patch requests to NetBox\nInvoke-NetboxUpsert -Uri ipam/prefixes/ -FindBy 'vlan.vid' -Properties @{vlan=@{vid=3999}; description='example'} -Multi -NoUpdate\n\n\n\n#### Example on how to loop through structure and upsert info in NetBox (only update if there's changes)\n\n$sites = @(\n    @{\n        name = 'netboxing-test-site1'\n        devices = @(\n            @{\n                name = 'netboxing-test-dev1'\n                nics = @(\n                    @{name = 'netboxing-test-nic1-1'; ip = @('10.99.99.1','10.99.99.2')}\n                    @{name = 'netboxing-test-nic1-2'; ip = @('10.99.99.3')}\n                )\n            }\n            @{\n                name = 'netboxing-test-dev2'\n                nics = @(\n                    @{name = 'netboxing-test-nic2-1'; ip = @('10.99.99.4')}\n                )\n            }\n            @{\n                name = 'netboxing-test-dev3'\n                nics = @(\n                    @{name = 'netboxing-test-nic3-1'}\n                )\n            }\n        )\n    }\n    @{\n        name = 'netboxing-test-site2'\n    }\n)\n\n$ErrorActionPreference = 'Stop'\n$nbRole = Invoke-NetboxUpsert -Uri dcim/device-roles/ -FindBy slug -Properties @{slug= 'netboxing-test-role1'; name = 'netboxing-test-role1'}\n$nbManufacturer = Invoke-NetboxUpsert -Uri dcim/manufacturers/ -FindBy slug -Properties @{slug= 'netboxing-test-manufacturer1'; name = 'netboxing-test-manufacturer1'}\n$nbType = Invoke-NetboxUpsert -Uri dcim/device-types/ -FindBy slug -Properties @{\n    slug         = 'netboxing-test-type1'\n    model        = 'netboxing-test-type1'\n    manufacturer = @{slug = 'netboxing-test-manufacturer1'}\n}\nforeach ($site in $sites)\n{\n    $nbSite = Invoke-NetboxUpsert -Uri dcim/sites/ -FindBy name -Properties @{name = $site.name} -PropertiesNew @{slug = $site.name}\n    foreach ($device in $site.devices)\n    {\n        $nbDevice = Invoke-NetboxUpsert -Uri dcim/devices/ -FindBy name -Properties @{name = $device.name} -PropertiesNew @{\n            site        = @{slug = $site.name}\n            device_role = @{slug = 'netboxing-test-role1'}\n            device_type = @{slug = 'netboxing-test-type1'}\n        }\n        foreach ($nic in $device.nics)\n        {\n            # The difference between \"Properties\" and \"PropertiesNew\" is that PropertiesNew only gets \n            # send to NetBox when creating a new object, not when updating/patching and existing object.\n            # So in this case, the \"type\" will not be changed to \"other\", if it's already another type in NetBox.\n            # But \"label\" will be changed to \"netboxing-test-label1\", if it's something else in NetBox.\n            $nbInterface = Invoke-NetboxUpsert -Uri dcim/interfaces/ -FindBy device.id,name -Properties @{\n                name = $nic.name\n                device = @{\n                    id = $nbDevice.id\n                }\n                label = 'netboxing-test-label1'\n            } -PropertiesNew @{\n                type = @{\n                    value     = 'other'  # Expand so \"type=other\" - and not \"type={value=other}\" when sending data to Netbox.\n                    ___EXPAND = 'value'  # We could also just have written \u003cValue='other'\u003e, and avoided the \"___EXPAND\".\n                }\n            }\n            foreach ($ip in $nic.ip)\n            {\n                $nbIp = Invoke-NetboxUpsert -Uri ipam/ip-addresses/ -FindBy interface_id=assigned_object_id,address -Properties @{\n                    address              = \"$ip/32\"\n                    assigned_object_type = 'dcim.interface'\n                    assigned_object_id   = $nbInterface.id\n                }\n            }\n        }\n    }\n}\n\n```\n\nExamples are also found in [EXAMPLES.ps1](EXAMPLES.ps1).\n\n### Functions\n\nSee [FUNCTIONS.md](FUNCTIONS.md) for documentation of functions in this module.\n\n## Install\n\n### Install module from PowerShell Gallery\n\n```powershell\nInstall-Module NetBoxing\n```\n\n### Install module from source\n\n```powershell\ngit clone https://github.com/thordreier/NetBoxing.git\ncd NetBoxing\ngit pull\n.\\Build.ps1 -InstallModule\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthordreier%2Fnetboxing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthordreier%2Fnetboxing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthordreier%2Fnetboxing/lists"}