Powershell module for Netbox
Find a file
Ben Claussen 44dcb252b8
v1.8.4 (#50)
* Fixing Interface Type parameter (#42)

* Fixing #41

* Update `deploy.ps1` to remove trailing whitespaces from psd1

* Increase version to 1.7.3

* Fix location of whitespace cleanup in `deploy.ps1`

* Device port support (#44)

* Fixing #41

* Correct for OTBS

* Start work on Front and Rear ports

* Revert "Start work on Front and Rear ports"

This reverts commit 257709fe2af5af5fbe4496b2d5b68481d80bf101.

* Fixing #41

* Add-NetboxDCIMRearPort function

* Revert "Revert "Start work on Front and Rear ports""

This reverts commit 4f6625af2d.

* Fix incorrect parameter variable types

* Parameter type adjustments

* Create function to get tag information

* Added Mark_Connected parameter

* Add Set-NetboxDCIMRearPort function

* Added Remove-NetboxDCIMRearPort function

* Added validate pattern for Color parameter

* Added Add-NetboxDCIMFrontPort function

* Fixed param list missing Force parameter

* Added Set-NetboxDCIMFrontPort function

* Added Remove-NetboxDCIMFrontPort function

* Init. functions for cables and cable terminations

* Reformatting using OTBS
Also working on defining tags by slug as an extra parameter, which appears
only in Add-NetboxDCIMRearPort currently

* Remove Tags_Slug parameter
In hindsight implementing would create extra work that could be hard to
maintain. Can be easily achieved outside of the function.

* Update psproj

* Fix braces

* Update Postman for Netbox v3.4.5

* Update vscode settings

* Update version 1.8.0

* Update psproj

* Update `uint16` to `uint64` where applicable for #49

* dev v1.8.1

* More `uint64` updates for #49

* `[uint64]` updates

* Add IPAMAddressRange functions

* Move limit/offset parameters to end of list

* Update psproj with IPAMAddressRange files

* Remove whitespaces

* Update version to 1.8.3

* Add Set-NetboxIPAMAddressRange

* Remove incorrect parameter

* Update version to 1.8.4

---------

Co-authored-by: SheffSix <jbeck1867@gmail.com>
Co-authored-by: James Beck <jim@beck81.co.uk>
2023-11-07 10:30:05 -05:00
.github/workflows Add release.(yml) Github Actions (#21) 2021-07-23 16:12:46 -04:00
.vscode v1.8.0 (#45) 2023-03-17 16:04:52 -04:00
Functions v1.8.4 (#50) 2023-11-07 10:30:05 -05:00
NetboxPS v1.8.4 (#50) 2023-11-07 10:30:05 -05:00
Postman v1.8.0 (#45) 2023-03-17 16:04:52 -04:00
Tests Merge branch 'dev' of https://github.com/benclaussen/NetboxPS into dev 2023-02-24 11:39:57 -05:00
.gitignore Add deploy.ps1 for PSS deploy workaround 2020-04-09 09:57:59 -04:00
_config.yml Set theme jekyll-theme-slate 2020-12-08 09:29:51 -05:00
deploy.ps1 v1.7.3 (#43) 2023-03-13 09:53:15 -04:00
LICENSE Add license 2018-05-18 12:19:15 -04:00
NetboxPS.psd1 v1.8.4 (#50) 2023-11-07 10:30:05 -05:00
NetboxPS.psm1 Fix conflicts for #38 2023-02-24 13:26:38 -05:00
NetboxPS.psproj v1.8.4 (#50) 2023-11-07 10:30:05 -05:00
NetboxPS.psproj.bak Project file updates 2018-10-18 12:56:18 -04:00
README.md Add Basic usage in README.md (#30) 2022-12-06 13:48:46 -05:00

NetboxPS

Powershell Netbox API module

Disclaimer

This module is beta. Use it at your own risk. I have only added functions as I have needed them, so not everything is available.

All functions are exported at the moment, including internal/private functions.

Description

This module is a wrapper for the Netbox API.

Usage

  1. Install module from the netboxPS folder
  2. Import module
  3. Connect to an API endpoint by using Connect-NetboxAPI -Hostname netbox.example.com

Basic Commands

#Just adding a new IP
New-NetboxIPAMAddress -Address 10.0.0.1/24 -Dns_name this.is.thedns.fqdn -Custom_Fields @{CustomFieldID="CustomFieldContent"} -Tenant 1 -Description "Description"

#Creating a new VM, add an interface and assign Interface IP
function New-NBVirtualMachine
{
    [CmdletBinding()]
    [Alias()]
    [OutputType([int])]
    Param
    (
        [string]$Name,
        [string]$Cluster,
        [string]$IP,
        [string]$tenant,
        [string]$VMNICName
    )

    Begin
    {
        $NBCluster = Get-NetboxVirtualizationCluster -name $Cluster
        $NBTenant = Get-NetboxTenant -Name $tenant
    }
    Process
    {
        $vm = New-NetboxVirtualMachine -Name $Name -Cluster $NBCluster.id -Tenant $NBtenant.id
        $interface = Add-NetboxVirtualMachineInterface -Name $VMNICName -Virtual_Machine $vm.id


        $NBip = New-NetboxIPAMAddress -Address $IP -Tenant $NBtenant.id 
        Set-NetboxIPAMAddress -Assigned_Object_Type virtualization.vminterface -Assigned_Object_Id $interface.id -id $NBip.id
        Set-NetboxVirtualMachine -Primary_IP4 $NBip.id -Id $vm.id
    }
}

Notes

I started this project years ago with Powershell Studio using the built in deployment methods, learning Git, and learning PS best practices. So please forgive any "obvious" mistakes 😅 Over time I have had to adjust my methods for deployment... change the design of functions, and refactor code as I learn new and better things.

This was built out of a need at my job to interact with Netbox for automation. Only recently has it become a "public" project with other collaborators (which I truly appreciate!). I have done my best to ensure each function does exactly one thing according to the API.

I will do my best to keep up, but please understand it is given attention as I can at work. As time permits, I will open issues for TODOs for things I have wanted to do for a while, just haven't had time or enough "need" to do them.

Contributing

I am always open to suggestions for improvement with reasons and data to back up the suggestion.