Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Functions/Setup/Connect-NetboxAPI.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,17 @@

Write-Verbose "Checking Netbox version compatibility"
$script:NetboxConfig.NetboxVersion = Get-NetboxVersion
if ([version]$script:NetboxConfig.NetboxVersion.'netbox-version' -lt 2.8) {
if ([version]$script:NetboxConfig.NetboxVersion.'netbox-version' -lt 4.0.1) {
$Script:NetboxConfig.Connected = $false
throw "Netbox version is incompatible with this PS module. Requires >=2.8.*, found version $($script:NetboxConfig.NetboxVersion.'netbox-version')"
throw "Netbox version is incompatible with this PS module. Requires >=4.0, found version $($script:NetboxConfig.NetboxVersion.'netbox-version')"
} else {
Write-Verbose "Found compatible version [$($script:NetboxConfig.NetboxVersion.'netbox-version')]!"
}

$script:NetboxConfig.Connected = $true
Write-Verbose "Successfully connected!"

$script:NetboxConfig.ContentTypes = Get-NetboxContentType -Limit 500
$script:NetboxConfig.ObjectTypes = Get-NetboxObjectType -Limit 500

Write-Verbose "Connection process completed"
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
function Get-NetboxContentType {
function Get-NetboxObjectType {
<#
.SYNOPSIS
Get a content type definition from Netbox
Get a object type definition from Netbox

.DESCRIPTION
A detailed description of the Get-NetboxContentType function.
A detailed description of the Get-NetboxObjectType function.

.PARAMETER Model
A description of the Model parameter.
Expand All @@ -28,7 +28,7 @@
Return the unparsed data from the HTTP request

.EXAMPLE
PS C:\> Get-NetboxContentType
PS C:\> Get-NetboxObjectType

.NOTES
Additional information about the function.
Expand Down Expand Up @@ -61,8 +61,8 @@

switch ($PSCmdlet.ParameterSetName) {
'ById' {
foreach ($ContentType_ID in $Id) {
$Segments = [System.Collections.ArrayList]::new(@('extras', 'content-types', $ContentType_ID))
foreach ($ObjectType_ID in $Id) {
$Segments = [System.Collections.ArrayList]::new(@('extras', 'object-types', $ObjectType_ID))

$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'

Expand All @@ -75,7 +75,7 @@
}

default {
$Segments = [System.Collections.ArrayList]::new(@('extras', 'content-types'))
$Segments = [System.Collections.ArrayList]::new(@('extras', 'object-types'))

$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters

Expand Down
2 changes: 1 addition & 1 deletion Functions/Setup/Support/SetupNetboxConfigVariable.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
'Choices' = @{
}
'APIDefinition' = $null
'ContentTypes' = $null
'ObjectTypes' = $null
}
}

Expand Down
26 changes: 13 additions & 13 deletions Functions/Tenancy/ContactRoles/Set-NetboxContactRole.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@


function Set-NetboxContactRole {
<#
.SYNOPSIS
Expand Down Expand Up @@ -28,7 +28,7 @@ function Set-NetboxContactRole {
.NOTES
Additional information about the function.
#>

[CmdletBinding(ConfirmImpact = 'Low',
SupportsShouldProcess = $true)]
[OutputType([pscustomobject])]
Expand All @@ -37,37 +37,37 @@ function Set-NetboxContactRole {
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true)]
[uint64[]]$Id,

[Parameter(ValueFromPipelineByPropertyName = $true)]
[ValidateLength(1, 100)]
[string]$Name,

[ValidateLength(1, 100)]
[ValidatePattern('^[-a-zA-Z0-9_]+$')]
[string]$Slug,

[ValidateLength(0, 200)]
[string]$Description,

[hashtable]$Custom_Fields,

[switch]$Raw
)

begin {
$Method = 'PATCH'
}

process {
foreach ($ContactRoleId in $Id) {
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contacts', $ContactRoleId))

$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'

$URI = BuildNewURI -Segments $URIComponents.Segments

$CurrentContactRole = Get-NetboxContactRole -Id $ContactRoleId -ErrorAction Stop

if ($Force -or $PSCmdlet.ShouldProcess($CurrentContactRole.Name, 'Update contact role')) {
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ function New-NetboxVirtualMachine {
[Parameter(Mandatory = $true)]
[string]$Name,

[Parameter(Mandatory = $true)]
[uint64]$Site,

[uint64]$Cluster,
Expand Down Expand Up @@ -45,8 +44,8 @@ function New-NetboxVirtualMachine {

#$PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus

if ($PSBoundParameters.ContainsKey('Cluster') -and (-not $PSBoundParameters.ContainsKey('Site'))) {
throw "You must specify a site ID with a cluster ID"
if (-not $PSBoundParameters.ContainsKey('Cluster') -and (-not $PSBoundParameters.ContainsKey('Site'))) {
throw "A virtual machine must be assigned to a site and/or cluster."
}

$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines'))
Expand Down
75 changes: 37 additions & 38 deletions NetboxPS.psd1
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#
# Module manifest for module 'NetboxPS'
# Module manifest for module 'PSGet_NetboxPS'
#
# Generated by: Ben Claussen
#
# Generated on: 2023-11-09
# Generated on: 10/2/2024
#

@{
Expand Down Expand Up @@ -66,38 +66,42 @@ CLRVersion = '2.0.50727'
# FormatsToProcess = @()

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
NestedModules = @()
# NestedModules = @()

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = 'Add-NetboxDCIMFrontPort', 'Add-NetboxDCIMInterface',
'Add-NetboxDCIMInterfaceConnection', 'Add-NetboxDCIMRearPort',
'Add-NetboxVirtualMachineInterface', 'Clear-NetboxCredential',
'Connect-NetboxAPI', 'Get-ModelDefinition', 'Get-NetboxAPIDefinition',
'Get-NetboxCircuit', 'Get-NetboxCircuitProvider',
'Get-NetboxCircuitTermination', 'Get-NetboxCircuitType',
'Add-NetboxVirtualMachineInterface', 'BuildNewURI',
'BuildURIComponents', 'CheckNetboxIsConnected',
'Clear-NetboxCredential', 'Connect-NetboxAPI', 'CreateEnum',
'Get-ModelDefinition', 'Get-NetboxAPIDefinition',
'GetNetboxAPIErrorBody', 'Get-NetboxCircuit',
'Get-NetboxCircuitProvider', 'Get-NetboxCircuitTermination',
'Get-NetboxCircuitType', 'GetNetboxConfigVariable',
'Get-NetboxContact', 'Get-NetboxContactAssignment',
'Get-NetboxContactRole', 'Get-NetboxContentType',
'Get-NetboxCredential', 'Get-NetboxDCIMCable',
'Get-NetboxDCIMCableTermination', 'Get-NetboxDCIMDevice',
'Get-NetboxDCIMDeviceRole', 'Get-NetboxDCIMDeviceType',
'Get-NetboxDCIMFrontPort', 'Get-NetboxDCIMInterface',
'Get-NetboxDCIMInterfaceConnection', 'Get-NetboxDCIMPlatform',
'Get-NetboxDCIMRearPort', 'Get-NetboxDCIMSite', 'Get-NetboxHostname',
'Get-NetboxHostPort', 'Get-NetboxHostScheme',
'Get-NetboxInvokeParams', 'Get-NetboxIPAMAddress',
'Get-NetboxIPAMAddressRange', 'Get-NetboxIPAMAggregate',
'Get-NetboxIPAMAvailableIP', 'Get-NetboxIPAMPrefix',
'Get-NetboxIPAMRole', 'Get-NetboxIPAMVLAN', 'Get-NetboxTag',
'Get-NetboxTenant', 'Get-NetboxTimeout', 'Get-NetboxVersion',
'Get-NetboxContactRole', 'Get-NetboxCredential',
'Get-NetboxDCIMCable', 'Get-NetboxDCIMCableTermination',
'Get-NetboxDCIMDevice', 'Get-NetboxDCIMDeviceRole',
'Get-NetboxDCIMDeviceType', 'Get-NetboxDCIMFrontPort',
'Get-NetboxDCIMInterface', 'Get-NetboxDCIMInterfaceConnection',
'Get-NetboxDCIMPlatform', 'Get-NetboxDCIMRearPort',
'Get-NetboxDCIMSite', 'Get-NetboxHostname', 'Get-NetboxHostPort',
'Get-NetboxHostScheme', 'Get-NetboxInvokeParams',
'Get-NetboxIPAMAddress', 'Get-NetboxIPAMAddressRange',
'Get-NetboxIPAMAggregate', 'Get-NetboxIPAMAvailableIP',
'Get-NetboxIPAMPrefix', 'Get-NetboxIPAMRole', 'Get-NetboxIPAMVLAN',
'Get-NetboxObjectType', 'Get-NetboxTag', 'Get-NetboxTenant',
'Get-NetboxTimeout', 'Get-NetboxVersion',
'Get-NetboxVirtualizationCluster',
'Get-NetboxVirtualizationClusterGroup', 'Get-NetboxVirtualMachine',
'Get-NetboxVirtualMachineInterface', 'New-NetboxCircuit',
'New-NetboxContact', 'New-NetboxContactAssignment',
'New-NetboxContactRole', 'New-NetboxDCIMDevice', 'New-NetboxDCIMSite',
'New-NetboxIPAMAddress', 'New-NetboxIPAMAddressRange',
'New-NetboxIPAMPrefix', 'New-NetboxIPAMVLAN', 'New-NetboxTenant',
'New-NetboxVirtualMachine', 'Remove-NetboxDCIMDevice',
'Remove-NetboxDCIMFrontPort', 'Remove-NetboxDCIMInterface',
'Get-NetboxVirtualMachineInterface', 'InvokeNetboxRequest',
'New-NetboxCircuit', 'New-NetboxContact',
'New-NetboxContactAssignment', 'New-NetboxContactRole',
'New-NetboxDCIMDevice', 'New-NetboxDCIMSite', 'New-NetboxIPAMAddress',
'New-NetboxIPAMAddressRange', 'New-NetboxIPAMPrefix',
'New-NetboxIPAMVLAN', 'New-NetboxTenant', 'New-NetboxVirtualMachine',
'Remove-NetboxDCIMDevice', 'Remove-NetboxDCIMFrontPort',
'Remove-NetboxDCIMInterface',
'Remove-NetboxDCIMInterfaceConnection', 'Remove-NetboxDCIMRearPort',
'Remove-NetboxDCIMSite', 'Remove-NetboxIPAMAddress',
'Remove-NetboxIPAMAddressRange', 'Remove-NetboxVirtualMachine',
Expand All @@ -111,16 +115,17 @@ FunctionsToExport = 'Add-NetboxDCIMFrontPort', 'Add-NetboxDCIMInterface',
'Set-NetboxIPAMAddressRange', 'Set-NetboxIPAMPrefix',
'Set-NetboxTimeout', 'Set-NetboxUnstrustedSSL',
'Set-NetboxVirtualMachine', 'Set-NetboxVirtualMachineInterface',
'Test-NetboxAPIConnected'
'SetupNetboxConfigVariable', 'Test-NetboxAPIConnected',
'ThrowNetboxRESTError', 'VerifyAPIConnectivity'

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = '*'
CmdletsToExport = @()

# Variables to export from this module
VariablesToExport = '*'
# VariablesToExport = @()

# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = '*'
AliasesToExport = @()

# DSC resources to export from this module
# DscResourcesToExport = @()
Expand Down Expand Up @@ -151,14 +156,8 @@ PrivateData = @{
# ReleaseNotes of this module
# ReleaseNotes = ''

# Prerelease string of this module
# Prerelease = ''

# Flag to indicate whether the module requires explicit user acceptance for install/update/save
# RequireLicenseAcceptance = $false

# External dependent modules of this module
# ExternalModuleDependencies = @()
# ExternalModuleDependencies = ''

} # End of PSData hashtable

Expand Down
75 changes: 37 additions & 38 deletions NetboxPS/NetboxPS.psd1
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#
# Module manifest for module 'NetboxPS'
# Module manifest for module 'PSGet_NetboxPS'
#
# Generated by: Ben Claussen
#
# Generated on: 2023-11-09
# Generated on: 10/2/2024
#

@{
Expand Down Expand Up @@ -66,38 +66,42 @@ CLRVersion = '2.0.50727'
# FormatsToProcess = @()

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
NestedModules = @()
# NestedModules = @()

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = 'Add-NetboxDCIMFrontPort', 'Add-NetboxDCIMInterface',
'Add-NetboxDCIMInterfaceConnection', 'Add-NetboxDCIMRearPort',
'Add-NetboxVirtualMachineInterface', 'Clear-NetboxCredential',
'Connect-NetboxAPI', 'Get-ModelDefinition', 'Get-NetboxAPIDefinition',
'Get-NetboxCircuit', 'Get-NetboxCircuitProvider',
'Get-NetboxCircuitTermination', 'Get-NetboxCircuitType',
'Add-NetboxVirtualMachineInterface', 'BuildNewURI',
'BuildURIComponents', 'CheckNetboxIsConnected',
'Clear-NetboxCredential', 'Connect-NetboxAPI', 'CreateEnum',
'Get-ModelDefinition', 'Get-NetboxAPIDefinition',
'GetNetboxAPIErrorBody', 'Get-NetboxCircuit',
'Get-NetboxCircuitProvider', 'Get-NetboxCircuitTermination',
'Get-NetboxCircuitType', 'GetNetboxConfigVariable',
'Get-NetboxContact', 'Get-NetboxContactAssignment',
'Get-NetboxContactRole', 'Get-NetboxContentType',
'Get-NetboxCredential', 'Get-NetboxDCIMCable',
'Get-NetboxDCIMCableTermination', 'Get-NetboxDCIMDevice',
'Get-NetboxDCIMDeviceRole', 'Get-NetboxDCIMDeviceType',
'Get-NetboxDCIMFrontPort', 'Get-NetboxDCIMInterface',
'Get-NetboxDCIMInterfaceConnection', 'Get-NetboxDCIMPlatform',
'Get-NetboxDCIMRearPort', 'Get-NetboxDCIMSite', 'Get-NetboxHostname',
'Get-NetboxHostPort', 'Get-NetboxHostScheme',
'Get-NetboxInvokeParams', 'Get-NetboxIPAMAddress',
'Get-NetboxIPAMAddressRange', 'Get-NetboxIPAMAggregate',
'Get-NetboxIPAMAvailableIP', 'Get-NetboxIPAMPrefix',
'Get-NetboxIPAMRole', 'Get-NetboxIPAMVLAN', 'Get-NetboxTag',
'Get-NetboxTenant', 'Get-NetboxTimeout', 'Get-NetboxVersion',
'Get-NetboxContactRole', 'Get-NetboxCredential',
'Get-NetboxDCIMCable', 'Get-NetboxDCIMCableTermination',
'Get-NetboxDCIMDevice', 'Get-NetboxDCIMDeviceRole',
'Get-NetboxDCIMDeviceType', 'Get-NetboxDCIMFrontPort',
'Get-NetboxDCIMInterface', 'Get-NetboxDCIMInterfaceConnection',
'Get-NetboxDCIMPlatform', 'Get-NetboxDCIMRearPort',
'Get-NetboxDCIMSite', 'Get-NetboxHostname', 'Get-NetboxHostPort',
'Get-NetboxHostScheme', 'Get-NetboxInvokeParams',
'Get-NetboxIPAMAddress', 'Get-NetboxIPAMAddressRange',
'Get-NetboxIPAMAggregate', 'Get-NetboxIPAMAvailableIP',
'Get-NetboxIPAMPrefix', 'Get-NetboxIPAMRole', 'Get-NetboxIPAMVLAN',
'Get-NetboxObjectType', 'Get-NetboxTag', 'Get-NetboxTenant',
'Get-NetboxTimeout', 'Get-NetboxVersion',
'Get-NetboxVirtualizationCluster',
'Get-NetboxVirtualizationClusterGroup', 'Get-NetboxVirtualMachine',
'Get-NetboxVirtualMachineInterface', 'New-NetboxCircuit',
'New-NetboxContact', 'New-NetboxContactAssignment',
'New-NetboxContactRole', 'New-NetboxDCIMDevice', 'New-NetboxDCIMSite',
'New-NetboxIPAMAddress', 'New-NetboxIPAMAddressRange',
'New-NetboxIPAMPrefix', 'New-NetboxIPAMVLAN', 'New-NetboxTenant',
'New-NetboxVirtualMachine', 'Remove-NetboxDCIMDevice',
'Remove-NetboxDCIMFrontPort', 'Remove-NetboxDCIMInterface',
'Get-NetboxVirtualMachineInterface', 'InvokeNetboxRequest',
'New-NetboxCircuit', 'New-NetboxContact',
'New-NetboxContactAssignment', 'New-NetboxContactRole',
'New-NetboxDCIMDevice', 'New-NetboxDCIMSite', 'New-NetboxIPAMAddress',
'New-NetboxIPAMAddressRange', 'New-NetboxIPAMPrefix',
'New-NetboxIPAMVLAN', 'New-NetboxTenant', 'New-NetboxVirtualMachine',
'Remove-NetboxDCIMDevice', 'Remove-NetboxDCIMFrontPort',
'Remove-NetboxDCIMInterface',
'Remove-NetboxDCIMInterfaceConnection', 'Remove-NetboxDCIMRearPort',
'Remove-NetboxDCIMSite', 'Remove-NetboxIPAMAddress',
'Remove-NetboxIPAMAddressRange', 'Remove-NetboxVirtualMachine',
Expand All @@ -111,16 +115,17 @@ FunctionsToExport = 'Add-NetboxDCIMFrontPort', 'Add-NetboxDCIMInterface',
'Set-NetboxIPAMAddressRange', 'Set-NetboxIPAMPrefix',
'Set-NetboxTimeout', 'Set-NetboxUnstrustedSSL',
'Set-NetboxVirtualMachine', 'Set-NetboxVirtualMachineInterface',
'Test-NetboxAPIConnected'
'SetupNetboxConfigVariable', 'Test-NetboxAPIConnected',
'ThrowNetboxRESTError', 'VerifyAPIConnectivity'

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = '*'
CmdletsToExport = @()

# Variables to export from this module
VariablesToExport = '*'
# VariablesToExport = @()

# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = '*'
AliasesToExport = @()

# DSC resources to export from this module
# DscResourcesToExport = @()
Expand Down Expand Up @@ -151,14 +156,8 @@ PrivateData = @{
# ReleaseNotes of this module
# ReleaseNotes = ''

# Prerelease string of this module
# Prerelease = ''

# Flag to indicate whether the module requires explicit user acceptance for install/update/save
# RequireLicenseAcceptance = $false

# External dependent modules of this module
# ExternalModuleDependencies = @()
# ExternalModuleDependencies = ''

} # End of PSData hashtable

Expand Down
Loading