mirror of
https://github.com/benclaussen/NetboxPS.git
synced 2025-12-16 11:15:46 +00:00
Compare commits
No commits in common. "dev" and "v1.4.0" have entirely different histories.
111 changed files with 5682 additions and 72014 deletions
16
.github/workflows/release.yml
vendored
16
.github/workflows/release.yml
vendored
|
|
@ -1,16 +0,0 @@
|
||||||
name: Release
|
|
||||||
|
|
||||||
on:
|
|
||||||
release:
|
|
||||||
types: [published]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v1
|
|
||||||
- name: Publish
|
|
||||||
run: |
|
|
||||||
pwsh -Command "Publish-Module -Path ./NetboxPS -NuGetApiKey ${{ secrets.PSGALLERY_API_KEY }}"
|
|
||||||
22
.vscode/settings.json
vendored
22
.vscode/settings.json
vendored
|
|
@ -1,22 +0,0 @@
|
||||||
// Place your settings in this file to overwrite default and user settings.
|
|
||||||
{
|
|
||||||
"editor.formatOnSave": true,
|
|
||||||
"files.trimTrailingWhitespace": true,
|
|
||||||
"powershell.scriptAnalysis.settingsPath": ".vscode/PSScriptAnalyzerSettings.psd1",
|
|
||||||
"powershell.codeFormatting.newLineAfterCloseBrace": false,
|
|
||||||
"powershell.codeFormatting.useCorrectCasing": true,
|
|
||||||
"powershell.codeFormatting.preset": "OTBS",
|
|
||||||
"powershell.codeFormatting.addWhitespaceAroundPipe": true,
|
|
||||||
"powershell.codeFormatting.autoCorrectAliases": true,
|
|
||||||
"powershell.codeFormatting.newLineAfterCloseBrace": true,
|
|
||||||
"powershell.codeFormatting.newLineAfterOpenBrace": true,
|
|
||||||
"powershell.codeFormatting.openBraceOnSameLine": true,
|
|
||||||
"powershell.codeFormatting.whitespaceAfterSeparator": true,
|
|
||||||
"powershell.codeFormatting.whitespaceAroundOperator": true,
|
|
||||||
"powershell.codeFormatting.whitespaceBeforeOpenBrace": true,
|
|
||||||
"powershell.codeFormatting.whitespaceBeforeOpenParen": true,
|
|
||||||
"powershell.codeFormatting.trimWhitespaceAroundPipe": true,
|
|
||||||
"[markdown]": {
|
|
||||||
"files.trimTrailingWhitespace": false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
14
Functions/Circuits/Circuits.ps1
Normal file
14
Functions/Circuits/Circuits.ps1
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2018 v5.5.148
|
||||||
|
Created on: 2/28/2018 4:06 PM
|
||||||
|
Created by: Ben Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Circuits.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
Circuit object functions
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,120 +1,131 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/23/2020 12:15
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Get-NetboxCircuit.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxCircuit {
|
function Get-NetboxCircuit {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Gets one or more circuits
|
Gets one or more circuits
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
A detailed description of the Get-NetboxCircuit function.
|
A detailed description of the Get-NetboxCircuit function.
|
||||||
|
|
||||||
.PARAMETER Id
|
.PARAMETER Id
|
||||||
Database ID of circuit. This will query for exactly the IDs provided
|
Database ID of circuit. This will query for exactly the IDs provided
|
||||||
|
|
||||||
.PARAMETER CID
|
.PARAMETER CID
|
||||||
Circuit ID
|
Circuit ID
|
||||||
|
|
||||||
.PARAMETER InstallDate
|
.PARAMETER InstallDate
|
||||||
Date of installation
|
Date of installation
|
||||||
|
|
||||||
.PARAMETER CommitRate
|
.PARAMETER CommitRate
|
||||||
Committed rate in Kbps
|
Committed rate in Kbps
|
||||||
|
|
||||||
.PARAMETER Query
|
.PARAMETER Query
|
||||||
A raw search query... As if you were searching the web site
|
A raw search query... As if you were searching the web site
|
||||||
|
|
||||||
.PARAMETER Provider
|
.PARAMETER Provider
|
||||||
The name or ID of the provider. Provide either [string] or [uint64]. String will search provider names, integer will search database IDs
|
The name or ID of the provider. Provide either [string] or [int]. String will search provider names, integer will search database IDs
|
||||||
|
|
||||||
.PARAMETER Type
|
.PARAMETER Type
|
||||||
Type of circuit. Provide either [string] or [uint64]. String will search provider type names, integer will search database IDs
|
Type of circuit. Provide either [string] or [int]. String will search provider type names, integer will search database IDs
|
||||||
|
|
||||||
.PARAMETER Site
|
.PARAMETER Site
|
||||||
Location/site of circuit. Provide either [string] or [uint64]. String will search site names, integer will search database IDs
|
Location/site of circuit. Provide either [string] or [int]. String will search site names, integer will search database IDs
|
||||||
|
|
||||||
.PARAMETER Tenant
|
.PARAMETER Tenant
|
||||||
Tenant assigned to circuit. Provide either [string] or [uint64]. String will search tenant names, integer will search database IDs
|
Tenant assigned to circuit. Provide either [string] or [int]. String will search tenant names, integer will search database IDs
|
||||||
|
|
||||||
.PARAMETER Limit
|
.PARAMETER Limit
|
||||||
A description of the Limit parameter.
|
A description of the Limit parameter.
|
||||||
|
|
||||||
.PARAMETER Offset
|
.PARAMETER Offset
|
||||||
A description of the Offset parameter.
|
A description of the Offset parameter.
|
||||||
|
|
||||||
.PARAMETER Raw
|
.PARAMETER Raw
|
||||||
A description of the Raw parameter.
|
A description of the Raw parameter.
|
||||||
|
|
||||||
.PARAMETER ID__IN
|
.PARAMETER ID__IN
|
||||||
Multiple unique DB IDs to retrieve
|
Multiple unique DB IDs to retrieve
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> Get-NetboxCircuit
|
PS C:\> Get-NetboxCircuit
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Additional information about the function.
|
Additional information about the function.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(ParameterSetName = 'ById')]
|
[Parameter(ParameterSetName = 'ById')]
|
||||||
[uint64[]]$Id,
|
[uint16[]]$Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$CID,
|
[string]$CID,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[datetime]$InstallDate,
|
[datetime]$InstallDate,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint64]$CommitRate,
|
[uint32]$CommitRate,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Query,
|
[string]$Query,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[object]$Provider,
|
[object]$Provider,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[object]$Type,
|
[object]$Type,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Site,
|
[string]$Site,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Tenant,
|
[string]$Tenant,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint16]$Limit,
|
[uint16]$Limit,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint16]$Offset,
|
[uint16]$Offset,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
process {
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
switch ($PSCmdlet.ParameterSetName) {
|
'ById' {
|
||||||
'ById' {
|
foreach ($i in $ID) {
|
||||||
foreach ($i in $ID) {
|
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'circuits', $i))
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'circuits', $i))
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName "Id"
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName "Id"
|
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
default {
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'circuits'))
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'circuits'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,55 +1,67 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.181
|
||||||
|
Created on: 2020-11-04 11:48
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: New-NetboxCircuit.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function New-NetboxCircuit {
|
function New-NetboxCircuit {
|
||||||
[CmdletBinding(ConfirmImpact = 'Low',
|
[CmdletBinding(ConfirmImpact = 'Low',
|
||||||
SupportsShouldProcess = $true)]
|
SupportsShouldProcess = $true)]
|
||||||
[OutputType([pscustomobject])]
|
[OutputType([pscustomobject])]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true,
|
[Parameter(Mandatory = $true,
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[string]$CID,
|
[string]$CID,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[uint64]$Provider,
|
[uint32]$Provider,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[uint64]$Type,
|
[uint32]$Type,
|
||||||
|
|
||||||
#[ValidateSet('Active', 'Planned', 'Provisioning', 'Offline', 'Deprovisioning', 'Decommissioned ')]
|
#[ValidateSet('Active', 'Planned', 'Provisioning', 'Offline', 'Deprovisioning', 'Decommissioned ')]
|
||||||
[uint16]$Status = 'Active',
|
[uint16]$Status = 'Active',
|
||||||
|
|
||||||
[string]$Description,
|
[string]$Description,
|
||||||
|
|
||||||
[uint64]$Tenant,
|
[uint32]$Tenant,
|
||||||
|
|
||||||
[string]$Termination_A,
|
[string]$Termination_A,
|
||||||
|
|
||||||
[datetime]$Install_Date,
|
[datetime]$Install_Date,
|
||||||
|
|
||||||
[string]$Termination_Z,
|
[string]$Termination_Z,
|
||||||
|
|
||||||
[ValidateRange(0, 2147483647)]
|
[ValidateRange(0, 2147483647)]
|
||||||
[uint64]$Commit_Rate,
|
[uint32]$Commit_Rate,
|
||||||
|
|
||||||
[string]$Comments,
|
[string]$Comments,
|
||||||
|
|
||||||
[hashtable]$Custom_Fields,
|
[hashtable]$Custom_Fields,
|
||||||
|
|
||||||
[switch]$Force,
|
[switch]$Force,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
process {
|
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'circuits'))
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'circuits'))
|
$Method = 'POST'
|
||||||
$Method = 'POST'
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
|
||||||
|
if ($Force -or $PSCmdlet.ShouldProcess($CID, 'Create new circuit')) {
|
||||||
if ($Force -or $PSCmdlet.ShouldProcess($CID, 'Create new circuit')) {
|
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
||||||
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,57 +1,71 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.181
|
||||||
|
Created on: 2020-11-04 12:06
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Get-NetboxCircuitProvider.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxCircuitProvider {
|
function Get-NetboxCircuitProvider {
|
||||||
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(ParameterSetName = 'ById',
|
[Parameter(ParameterSetName = 'ById',
|
||||||
Mandatory = $true)]
|
Mandatory = $true)]
|
||||||
[uint64[]]$Id,
|
[uint16[]]$Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query',
|
[Parameter(ParameterSetName = 'Query',
|
||||||
Mandatory = $false)]
|
Mandatory = $false)]
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Query,
|
[string]$Query,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Slug,
|
[string]$Slug,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$ASN,
|
[string]$ASN,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Account,
|
[string]$Account,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint16]$Limit,
|
[uint16]$Limit,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint16]$Offset,
|
[uint16]$Offset,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
switch ($PSCmdlet.ParameterSetName) {
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
'ById' {
|
'ById' {
|
||||||
foreach ($i in $ID) {
|
foreach ($i in $ID) {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'providers', $i))
|
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'providers', $i))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName "Id"
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName "Id"
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
default {
|
default {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'providers'))
|
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'providers'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,63 +1,77 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.181
|
||||||
|
Created on: 2020-11-04 10:22
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Get-NetboxCircuitTermination.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxCircuitTermination {
|
function Get-NetboxCircuitTermination {
|
||||||
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(ParameterSetName = 'ById',
|
[Parameter(ParameterSetName = 'ById',
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[uint64[]]$Id,
|
[uint32[]]$Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Circuit_ID,
|
[string]$Circuit_ID,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Term_Side,
|
[string]$Term_Side,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint64]$Port_Speed,
|
[uint32]$Port_Speed,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Query,
|
[string]$Query,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Site_ID,
|
[string]$Site_ID,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Site,
|
[string]$Site,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$XConnect_ID,
|
[string]$XConnect_ID,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint16]$Limit,
|
[uint16]$Limit,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint16]$Offset,
|
[uint16]$Offset,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
process {
|
process {
|
||||||
switch ($PSCmdlet.ParameterSetName) {
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
'ById' {
|
'ById' {
|
||||||
foreach ($i in $ID) {
|
foreach ($i in $ID) {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'circuit-terminations', $i))
|
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'circuit-terminations', $i))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName "Id"
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName "Id"
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
default {
|
default {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'circuit-terminations'))
|
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'circuit-terminations'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,49 +1,63 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.181
|
||||||
|
Created on: 2020-11-04 12:34
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Get-NetboxCircuitType.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxCircuitType {
|
function Get-NetboxCircuitType {
|
||||||
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(ParameterSetName = 'ById')]
|
[Parameter(ParameterSetName = 'ById')]
|
||||||
[uint64[]]$Id,
|
[uint16[]]$Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Slug,
|
[string]$Slug,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Query,
|
[string]$Query,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint16]$Limit,
|
[uint16]$Limit,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint16]$Offset,
|
[uint16]$Offset,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
switch ($PSCmdlet.ParameterSetName) {
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
'ById' {
|
'ById' {
|
||||||
foreach ($i in $ID) {
|
foreach ($i in $ID) {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'circuit_types', $i))
|
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'circuit_types', $i))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName "Id"
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName "Id"
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
default {
|
default {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'circuit-types'))
|
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'circuit-types'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
function Get-NetboxDCIMCableTermination {
|
|
||||||
[CmdletBinding()]
|
|
||||||
#region Parameters
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[uint16]$Limit,
|
|
||||||
|
|
||||||
[uint16]$Offset,
|
|
||||||
|
|
||||||
[Parameter(ValueFromPipelineByPropertyName = $true)]
|
|
||||||
[uint64[]]$Id,
|
|
||||||
|
|
||||||
[uint64]$Cable,
|
|
||||||
|
|
||||||
[string]$Cable_End,
|
|
||||||
|
|
||||||
[string]$Termination_Type,
|
|
||||||
|
|
||||||
[uint64]$Termination_ID,
|
|
||||||
|
|
||||||
[switch]$Raw
|
|
||||||
)
|
|
||||||
|
|
||||||
#endregion Parameters
|
|
||||||
|
|
||||||
process {
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'cable-terminations'))
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
|
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,55 +0,0 @@
|
||||||
function Get-NetboxDCIMCable {
|
|
||||||
[CmdletBinding()]
|
|
||||||
#region Parameters
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[uint16]$Limit,
|
|
||||||
|
|
||||||
[uint16]$Offset,
|
|
||||||
|
|
||||||
[Parameter(ValueFromPipelineByPropertyName = $true)]
|
|
||||||
[uint64[]]$Id,
|
|
||||||
|
|
||||||
[string]$Label,
|
|
||||||
|
|
||||||
[string]$Termination_A_Type,
|
|
||||||
|
|
||||||
[uint64]$Termination_A_ID,
|
|
||||||
|
|
||||||
[string]$Termination_B_Type,
|
|
||||||
|
|
||||||
[uint64]$Termination_B_ID,
|
|
||||||
|
|
||||||
[string]$Type,
|
|
||||||
|
|
||||||
[string]$Status,
|
|
||||||
|
|
||||||
[string]$Color,
|
|
||||||
|
|
||||||
[uint64]$Device_ID,
|
|
||||||
|
|
||||||
[string]$Device,
|
|
||||||
|
|
||||||
[uint64]$Rack_Id,
|
|
||||||
|
|
||||||
[string]$Rack,
|
|
||||||
|
|
||||||
[uint64]$Location_ID,
|
|
||||||
|
|
||||||
[string]$Location,
|
|
||||||
|
|
||||||
[switch]$Raw
|
|
||||||
)
|
|
||||||
|
|
||||||
#endregion Parameters
|
|
||||||
|
|
||||||
process {
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'cables'))
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
|
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,84 +1,99 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/23/2020 12:06
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Get-NetboxDCIMDevice.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxDCIMDevice {
|
function Get-NetboxDCIMDevice {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
#region Parameters
|
#region Parameters
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[uint16]$Limit,
|
[uint16]$Limit,
|
||||||
|
|
||||||
[uint16]$Offset,
|
[uint16]$Offset,
|
||||||
|
|
||||||
[Parameter(ValueFromPipelineByPropertyName = $true)]
|
[Parameter(ValueFromPipelineByPropertyName = $true)]
|
||||||
[uint64[]]$Id,
|
[uint16[]]$Id,
|
||||||
|
|
||||||
[string]$Query,
|
[string]$Query,
|
||||||
|
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[uint64]$Manufacturer_Id,
|
[uint16]$Manufacturer_Id,
|
||||||
|
|
||||||
[string]$Manufacturer,
|
[string]$Manufacturer,
|
||||||
|
|
||||||
[uint64]$Device_Type_Id,
|
[uint16]$Device_Type_Id,
|
||||||
|
|
||||||
[uint64]$Role_Id,
|
[uint16]$Role_Id,
|
||||||
|
|
||||||
[string]$Role,
|
[string]$Role,
|
||||||
|
|
||||||
[uint64]$Tenant_Id,
|
[uint16]$Tenant_Id,
|
||||||
|
|
||||||
[string]$Tenant,
|
[string]$Tenant,
|
||||||
|
|
||||||
[uint64]$Platform_Id,
|
[uint16]$Platform_Id,
|
||||||
|
|
||||||
[string]$Platform,
|
[string]$Platform,
|
||||||
|
|
||||||
[string]$Asset_Tag,
|
[string]$Asset_Tag,
|
||||||
|
|
||||||
[uint64]$Site_Id,
|
[uint16]$Site_Id,
|
||||||
|
|
||||||
[string]$Site,
|
[string]$Site,
|
||||||
|
|
||||||
[uint64]$Rack_Group_Id,
|
[uint16]$Rack_Group_Id,
|
||||||
|
|
||||||
[uint64]$Rack_Id,
|
[uint16]$Rack_Id,
|
||||||
|
|
||||||
[uint64]$Cluster_Id,
|
[uint16]$Cluster_Id,
|
||||||
|
|
||||||
[uint64]$Model,
|
[uint16]$Model,
|
||||||
|
|
||||||
[object]$Status,
|
[object]$Status,
|
||||||
|
|
||||||
[bool]$Is_Full_Depth,
|
[bool]$Is_Full_Depth,
|
||||||
|
|
||||||
[bool]$Is_Console_Server,
|
[bool]$Is_Console_Server,
|
||||||
|
|
||||||
[bool]$Is_PDU,
|
[bool]$Is_PDU,
|
||||||
|
|
||||||
[bool]$Is_Network_Device,
|
[bool]$Is_Network_Device,
|
||||||
|
|
||||||
[string]$MAC_Address,
|
[string]$MAC_Address,
|
||||||
|
|
||||||
[bool]$Has_Primary_IP,
|
[bool]$Has_Primary_IP,
|
||||||
|
|
||||||
[uint64]$Virtual_Chassis_Id,
|
[uint16]$Virtual_Chassis_Id,
|
||||||
|
|
||||||
[uint16]$Position,
|
[uint16]$Position,
|
||||||
|
|
||||||
[string]$Serial,
|
[string]$Serial,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
#endregion Parameters
|
#endregion Parameters
|
||||||
|
|
||||||
process {
|
if ($null -ne $Status) {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'devices'))
|
$PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
|
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'devices'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
}
|
}
|
||||||
|
|
@ -1,48 +1,61 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/23/2020 12:07
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Get-NetboxDCIMDeviceRole.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxDCIMDeviceRole {
|
function Get-NetboxDCIMDeviceRole {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[uint16]$Limit,
|
[uint16]$Limit,
|
||||||
|
|
||||||
[uint16]$Offset,
|
[uint16]$Offset,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'ById')]
|
[Parameter(ParameterSetName = 'ById')]
|
||||||
[uint64[]]$Id,
|
[uint16[]]$Id,
|
||||||
|
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[string]$Slug,
|
[string]$Slug,
|
||||||
|
|
||||||
[string]$Color,
|
[string]$Color,
|
||||||
|
|
||||||
[bool]$VM_Role,
|
[bool]$VM_Role,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
switch ($PSCmdlet.ParameterSetName) {
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
'ById' {
|
'ById' {
|
||||||
foreach ($DRId in $Id) {
|
foreach ($DRId in $Id) {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'device-roles', $DRId))
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'device-roles', $DRId))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Raw'
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Raw'
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
}
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
default {
|
default {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'device-roles'))
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'device-roles'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,48 +1,61 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/23/2020 12:07
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Get-NetboxDCIMDeviceType.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxDCIMDeviceType {
|
function Get-NetboxDCIMDeviceType {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
#region Parameters
|
#region Parameters
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[uint16]$Offset,
|
[uint16]$Offset,
|
||||||
|
|
||||||
[uint16]$Limit,
|
[uint16]$Limit,
|
||||||
|
|
||||||
[uint64[]]$Id,
|
[uint16[]]$Id,
|
||||||
|
|
||||||
[string]$Query,
|
[string]$Query,
|
||||||
|
|
||||||
[string]$Slug,
|
[string]$Slug,
|
||||||
|
|
||||||
[string]$Manufacturer,
|
[string]$Manufacturer,
|
||||||
|
|
||||||
[uint64]$Manufacturer_Id,
|
[uint16]$Manufacturer_Id,
|
||||||
|
|
||||||
[string]$Model,
|
[string]$Model,
|
||||||
|
|
||||||
[string]$Part_Number,
|
[string]$Part_Number,
|
||||||
|
|
||||||
[uint16]$U_Height,
|
[uint16]$U_Height,
|
||||||
|
|
||||||
[bool]$Is_Full_Depth,
|
[bool]$Is_Full_Depth,
|
||||||
|
|
||||||
[bool]$Is_Console_Server,
|
[bool]$Is_Console_Server,
|
||||||
|
|
||||||
[bool]$Is_PDU,
|
[bool]$Is_PDU,
|
||||||
|
|
||||||
[bool]$Is_Network_Device,
|
[bool]$Is_Network_Device,
|
||||||
|
|
||||||
[uint16]$Subdevice_Role,
|
[uint16]$Subdevice_Role,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
#endregion Parameters
|
#endregion Parameters
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'device-types'))
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'device-types'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
}
|
}
|
||||||
|
|
@ -1,64 +1,90 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/23/2020 12:08
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: New-NetboxDCIMDevice.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function New-NetboxDCIMDevice {
|
function New-NetboxDCIMDevice {
|
||||||
[CmdletBinding(ConfirmImpact = 'low',
|
[CmdletBinding()]
|
||||||
SupportsShouldProcess = $true)]
|
|
||||||
[OutputType([pscustomobject])]
|
[OutputType([pscustomobject])]
|
||||||
#region Parameters
|
#region Parameters
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[object]$Device_Role,
|
[object]$Device_Role,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[object]$Device_Type,
|
[object]$Device_Type,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[uint64]$Site,
|
[uint16]$Site,
|
||||||
|
|
||||||
[object]$Status = 'Active',
|
[object]$Status = 'Active',
|
||||||
|
|
||||||
[uint64]$Platform,
|
[uint16]$Platform,
|
||||||
|
|
||||||
[uint64]$Tenant,
|
[uint16]$Tenant,
|
||||||
|
|
||||||
[uint64]$Cluster,
|
[uint16]$Cluster,
|
||||||
|
|
||||||
[uint64]$Rack,
|
[uint16]$Rack,
|
||||||
|
|
||||||
[uint16]$Position,
|
[uint16]$Position,
|
||||||
|
|
||||||
[object]$Face,
|
[object]$Face,
|
||||||
|
|
||||||
[string]$Serial,
|
[string]$Serial,
|
||||||
|
|
||||||
[string]$Asset_Tag,
|
[string]$Asset_Tag,
|
||||||
|
|
||||||
[uint64]$Virtual_Chassis,
|
[uint16]$Virtual_Chassis,
|
||||||
|
|
||||||
[uint64]$VC_Priority,
|
[uint16]$VC_Priority,
|
||||||
|
|
||||||
[uint64]$VC_Position,
|
[uint16]$VC_Position,
|
||||||
|
|
||||||
[uint64]$Primary_IP4,
|
[uint16]$Primary_IP4,
|
||||||
|
|
||||||
[uint64]$Primary_IP6,
|
[uint16]$Primary_IP6,
|
||||||
|
|
||||||
[string]$Comments,
|
[string]$Comments,
|
||||||
|
|
||||||
[hashtable]$Custom_Fields
|
[hashtable]$Custom_Fields
|
||||||
)
|
)
|
||||||
#endregion Parameters
|
#endregion Parameters
|
||||||
|
|
||||||
|
# if ($null -ne $Device_Role) {
|
||||||
|
# # Validate device role?
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# if ($null -ne $Device_Type) {
|
||||||
|
# # Validate device type?
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# if ($null -ne $Status) {
|
||||||
|
# $PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# if ($null -ne $Face) {
|
||||||
|
# $PSBoundParameters.Face = ValidateDCIMChoice -ProvidedValue $Face -DeviceFace
|
||||||
|
# }
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'devices'))
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'devices'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
if ($PSCmdlet.ShouldProcess($Name, 'Create new Device')) {
|
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
|
||||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,55 +1,68 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/23/2020 12:08
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Remove-NetboxDCIMDevice.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function Remove-NetboxDCIMDevice {
|
function Remove-NetboxDCIMDevice {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Delete a device
|
Delete a device
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Deletes a device from Netbox by ID
|
Deletes a device from Netbox by ID
|
||||||
|
|
||||||
.PARAMETER Id
|
.PARAMETER Id
|
||||||
Database ID of the device
|
Database ID of the device
|
||||||
|
|
||||||
.PARAMETER Force
|
.PARAMETER Force
|
||||||
Force deletion without any prompts
|
Force deletion without any prompts
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> Remove-NetboxDCIMDevice -Id $value1
|
PS C:\> Remove-NetboxDCIMDevice -Id $value1
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Additional information about the function.
|
Additional information about the function.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding(ConfirmImpact = 'High',
|
[CmdletBinding(ConfirmImpact = 'High',
|
||||||
SupportsShouldProcess = $true)]
|
SupportsShouldProcess = $true)]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true,
|
[Parameter(Mandatory = $true,
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[uint64[]]$Id,
|
[uint16[]]$Id,
|
||||||
|
|
||||||
[switch]$Force
|
[switch]$Force
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
foreach ($DeviceID in $Id) {
|
foreach ($DeviceID in $Id) {
|
||||||
$CurrentDevice = Get-NetboxDCIMDevice -Id $DeviceID -ErrorAction Stop
|
$CurrentDevice = Get-NetboxDCIMDevice -Id $DeviceID -ErrorAction Stop
|
||||||
|
|
||||||
if ($Force -or $pscmdlet.ShouldProcess("Name: $($CurrentDevice.Name) | ID: $($CurrentDevice.Id)", "Remove")) {
|
if ($Force -or $pscmdlet.ShouldProcess("Name: $($CurrentDevice.Name) | ID: $($CurrentDevice.Id)", "Remove")) {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'devices', $CurrentDevice.Id))
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'devices', $CurrentDevice.Id))
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $Segments
|
$URI = BuildNewURI -Segments $Segments
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Method DELETE
|
InvokeNetboxRequest -URI $URI -Method DELETE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
end {
|
end {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,76 +1,95 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/23/2020 12:08
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Set-NetboxDCIMDevice.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function Set-NetboxDCIMDevice {
|
function Set-NetboxDCIMDevice {
|
||||||
[CmdletBinding(SupportsShouldProcess = $true)]
|
[CmdletBinding(SupportsShouldProcess = $true)]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true,
|
[Parameter(Mandatory = $true,
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[uint64[]]$Id,
|
[uint16[]]$Id,
|
||||||
|
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[object]$Device_Role,
|
[object]$Device_Role,
|
||||||
|
|
||||||
[object]$Device_Type,
|
[object]$Device_Type,
|
||||||
|
|
||||||
[uint64]$Site,
|
[uint16]$Site,
|
||||||
|
|
||||||
[object]$Status,
|
[object]$Status,
|
||||||
|
|
||||||
[uint64]$Platform,
|
[uint16]$Platform,
|
||||||
|
|
||||||
[uint64]$Tenant,
|
[uint16]$Tenant,
|
||||||
|
|
||||||
[uint64]$Cluster,
|
[uint16]$Cluster,
|
||||||
|
|
||||||
[uint64]$Rack,
|
[uint16]$Rack,
|
||||||
|
|
||||||
[uint16]$Position,
|
[uint16]$Position,
|
||||||
|
|
||||||
[object]$Face,
|
[object]$Face,
|
||||||
|
|
||||||
[string]$Serial,
|
[string]$Serial,
|
||||||
|
|
||||||
[string]$Asset_Tag,
|
[string]$Asset_Tag,
|
||||||
|
|
||||||
[uint64]$Virtual_Chassis,
|
[uint16]$Virtual_Chassis,
|
||||||
|
|
||||||
[uint64]$VC_Priority,
|
[uint16]$VC_Priority,
|
||||||
|
|
||||||
[uint64]$VC_Position,
|
[uint16]$VC_Position,
|
||||||
|
|
||||||
[uint64]$Primary_IP4,
|
[uint16]$Primary_IP4,
|
||||||
|
|
||||||
[uint64]$Primary_IP6,
|
[uint16]$Primary_IP6,
|
||||||
|
|
||||||
[string]$Comments,
|
[string]$Comments,
|
||||||
|
|
||||||
[hashtable]$Custom_Fields,
|
[hashtable]$Custom_Fields,
|
||||||
|
|
||||||
[switch]$Force
|
[switch]$Force
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
|
# if ($null -ne $Status) {
|
||||||
|
# $PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# if ($null -ne $Face) {
|
||||||
|
# $PSBoundParameters.Face = ValidateDCIMChoice -ProvidedValue $Face -DeviceFace
|
||||||
|
# }
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
foreach ($DeviceID in $Id) {
|
foreach ($DeviceID in $Id) {
|
||||||
$CurrentDevice = Get-NetboxDCIMDevice -Id $DeviceID -ErrorAction Stop
|
$CurrentDevice = Get-NetboxDCIMDevice -Id $DeviceID -ErrorAction Stop
|
||||||
|
|
||||||
if ($Force -or $pscmdlet.ShouldProcess("$($CurrentDevice.Name)", "Set")) {
|
if ($Force -or $pscmdlet.ShouldProcess("$($CurrentDevice.Name)", "Set")) {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'devices', $CurrentDevice.Id))
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'devices', $CurrentDevice.Id))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
|
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
end {
|
end {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
function Add-NetboxDCIMFrontPort {
|
|
||||||
[CmdletBinding()]
|
|
||||||
[OutputType([pscustomobject])]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[uint64]$Device,
|
|
||||||
|
|
||||||
[uint64]$Module,
|
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[string]$Name,
|
|
||||||
|
|
||||||
[string]$Label,
|
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[string]$Type,
|
|
||||||
|
|
||||||
[ValidatePattern('^[0-9a-f]{6}$')]
|
|
||||||
[string]$Color,
|
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[uint64]$Rear_Port,
|
|
||||||
|
|
||||||
[uint64]$Rear_Port_Position,
|
|
||||||
|
|
||||||
[string]$Description,
|
|
||||||
|
|
||||||
[bool]$Mark_Connected,
|
|
||||||
|
|
||||||
[uint16[]]$Tags
|
|
||||||
|
|
||||||
)
|
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'front-ports'))
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
|
|
||||||
}
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
function Get-NetboxDCIMFrontPort {
|
|
||||||
[CmdletBinding()]
|
|
||||||
[OutputType([pscustomobject])]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[uint16]$Limit,
|
|
||||||
|
|
||||||
[uint16]$Offset,
|
|
||||||
|
|
||||||
[Parameter(ValueFromPipelineByPropertyName = $true)]
|
|
||||||
[uint64]$Id,
|
|
||||||
|
|
||||||
[string]$Name,
|
|
||||||
|
|
||||||
[string]$Device,
|
|
||||||
|
|
||||||
[uint64]$Device_Id,
|
|
||||||
|
|
||||||
[string]$Type,
|
|
||||||
|
|
||||||
[switch]$Raw
|
|
||||||
)
|
|
||||||
|
|
||||||
process {
|
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'front-ports'))
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
function Remove-NetboxDCIMFrontPort {
|
|
||||||
|
|
||||||
[CmdletBinding(ConfirmImpact = 'High',
|
|
||||||
SupportsShouldProcess = $true)]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[Parameter(Mandatory = $true,
|
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
|
||||||
[uint64[]]$Id,
|
|
||||||
|
|
||||||
[switch]$Force
|
|
||||||
)
|
|
||||||
|
|
||||||
begin {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
process {
|
|
||||||
foreach ($FrontPortID in $Id) {
|
|
||||||
$CurrentPort = Get-NetboxDCIMFrontPort -Id $FrontPortID -ErrorAction Stop
|
|
||||||
|
|
||||||
if ($Force -or $pscmdlet.ShouldProcess("Name: $($CurrentPort.Name) | ID: $($CurrentPort.Id)", "Remove")) {
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'front-ports', $CurrentPort.Id))
|
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $Segments
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Method DELETE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
end {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,60 +0,0 @@
|
||||||
function Set-NetboxDCIMFrontPort {
|
|
||||||
[CmdletBinding(ConfirmImpact = 'Medium',
|
|
||||||
SupportsShouldProcess = $true)]
|
|
||||||
[OutputType([pscustomobject])]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[Parameter(Mandatory = $true,
|
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
|
||||||
[uint64[]]$Id,
|
|
||||||
|
|
||||||
[uint16]$Device,
|
|
||||||
|
|
||||||
[uint16]$Module,
|
|
||||||
|
|
||||||
[string]$Name,
|
|
||||||
|
|
||||||
[string]$Label,
|
|
||||||
|
|
||||||
[string]$Type,
|
|
||||||
|
|
||||||
[ValidatePattern('^[0-9a-f]{6}$')]
|
|
||||||
[string]$Color,
|
|
||||||
|
|
||||||
[uint64]$Rear_Port,
|
|
||||||
|
|
||||||
[uint16]$Rear_Port_Position,
|
|
||||||
|
|
||||||
[string]$Description,
|
|
||||||
|
|
||||||
[bool]$Mark_Connected,
|
|
||||||
|
|
||||||
[uint64[]]$Tags,
|
|
||||||
|
|
||||||
[switch]$Force
|
|
||||||
)
|
|
||||||
|
|
||||||
begin {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
process {
|
|
||||||
foreach ($FrontPortID in $Id) {
|
|
||||||
$CurrentPort = Get-NetboxDCIMFrontPort -Id $FrontPortID -ErrorAction Stop
|
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'front-ports', $CurrentPort.Id))
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $Segments
|
|
||||||
|
|
||||||
if ($Force -or $pscmdlet.ShouldProcess("Front Port ID $($CurrentPort.Id)", "Set")) {
|
|
||||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
end {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,49 +1,62 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/23/2020 12:13
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Get-NetboxDCIMPlatform.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxDCIMPlatform {
|
function Get-NetboxDCIMPlatform {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
[OutputType([pscustomobject])]
|
[OutputType([pscustomobject])]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[uint16]$Limit,
|
[uint16]$Limit,
|
||||||
|
|
||||||
[uint16]$Offset,
|
[uint16]$Offset,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'ById')]
|
[Parameter(ParameterSetName = 'ById')]
|
||||||
[uint64[]]$Id,
|
[uint16[]]$Id,
|
||||||
|
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[string]$Slug,
|
[string]$Slug,
|
||||||
|
|
||||||
[uint64]$Manufacturer_Id,
|
[uint16]$Manufacturer_Id,
|
||||||
|
|
||||||
[string]$Manufacturer,
|
[string]$Manufacturer,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
switch ($PSCmdlet.ParameterSetName) {
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
'ById' {
|
'ById' {
|
||||||
foreach ($PlatformID in $Id) {
|
foreach ($PlatformID in $Id) {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'platforms', $PlatformID))
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'platforms', $PlatformID))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Raw'
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Raw'
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
}
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
default {
|
default {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'platforms'))
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'platforms'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,70 +1,84 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/23/2020 12:10
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Add-NetboxDCIMInterface.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function Add-NetboxDCIMInterface {
|
function Add-NetboxDCIMInterface {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
[OutputType([pscustomobject])]
|
[OutputType([pscustomobject])]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[uint64]$Device,
|
[uint16]$Device,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[ValidateSet('virtual', 'bridge', 'lag', '100base-tx', '1000base-t', '2.5gbase-t', '5gbase-t', '10gbase-t', '10gbase-cx4', '1000base-x-gbic', '1000base-x-sfp', '10gbase-x-sfpp', '10gbase-x-xfp', '10gbase-x-xenpak', '10gbase-x-x2', '25gbase-x-sfp28', '50gbase-x-sfp56', '40gbase-x-qsfpp', '50gbase-x-sfp28', '100gbase-x-cfp', '100gbase-x-cfp2', '200gbase-x-cfp2', '100gbase-x-cfp4', '100gbase-x-cpak', '100gbase-x-qsfp28', '200gbase-x-qsfp56', '400gbase-x-qsfpdd', '400gbase-x-osfp', '1000base-kx', '10gbase-kr', '10gbase-kx4', '25gbase-kr', '40gbase-kr4', '50gbase-kr', '100gbase-kp4', '100gbase-kr2', '100gbase-kr4', 'ieee802.11a', 'ieee802.11g', 'ieee802.11n', 'ieee802.11ac', 'ieee802.11ad', 'ieee802.11ax', 'ieee802.11ay', 'ieee802.15.1', 'other-wireless', 'gsm', 'cdma', 'lte', 'sonet-oc3', 'sonet-oc12', 'sonet-oc48', 'sonet-oc192', 'sonet-oc768', 'sonet-oc1920', 'sonet-oc3840', '1gfc-sfp', '2gfc-sfp', '4gfc-sfp', '8gfc-sfpp', '16gfc-sfpp', '32gfc-sfp28', '64gfc-qsfpp', '128gfc-qsfp28', 'infiniband-sdr', 'infiniband-ddr', 'infiniband-qdr', 'infiniband-fdr10', 'infiniband-fdr', 'infiniband-edr', 'infiniband-hdr', 'infiniband-ndr', 'infiniband-xdr', 't1', 'e1', 't3', 'e3', 'xdsl', 'docsis', 'gpon', 'xg-pon', 'xgs-pon', 'ng-pon2', 'epon', '10g-epon', 'cisco-stackwise', 'cisco-stackwise-plus', 'cisco-flexstack', 'cisco-flexstack-plus', 'cisco-stackwise-80', 'cisco-stackwise-160', 'cisco-stackwise-320', 'cisco-stackwise-480', 'juniper-vcp', 'extreme-summitstack', 'extreme-summitstack-128', 'extreme-summitstack-256', 'extreme-summitstack-512', 'other', IgnoreCase = $true)]
|
|
||||||
[string]$Type,
|
|
||||||
|
|
||||||
[bool]$Enabled,
|
[bool]$Enabled,
|
||||||
|
|
||||||
[object]$Form_Factor,
|
[object]$Form_Factor,
|
||||||
|
|
||||||
[uint16]$MTU,
|
[uint16]$MTU,
|
||||||
|
|
||||||
[string]$MAC_Address,
|
[string]$MAC_Address,
|
||||||
|
|
||||||
[bool]$MGMT_Only,
|
[bool]$MGMT_Only,
|
||||||
|
|
||||||
[uint64]$LAG,
|
[uint16]$LAG,
|
||||||
|
|
||||||
[string]$Description,
|
[string]$Description,
|
||||||
|
|
||||||
[ValidateSet('Access', 'Tagged', 'Tagged All', '100', '200', '300', IgnoreCase = $true)]
|
[ValidateSet('Access', 'Tagged', 'Tagged All', '100', '200', '300', IgnoreCase = $true)]
|
||||||
[string]$Mode,
|
[string]$Mode,
|
||||||
|
|
||||||
[ValidateRange(1, 4094)]
|
[ValidateRange(1, 4094)]
|
||||||
[uint16]$Untagged_VLAN,
|
[uint16]$Untagged_VLAN,
|
||||||
|
|
||||||
[ValidateRange(1, 4094)]
|
[ValidateRange(1, 4094)]
|
||||||
[uint16[]]$Tagged_VLANs
|
[uint16[]]$Tagged_VLANs
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# if ($null -ne $Form_Factor) {
|
||||||
|
# $PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
|
||||||
|
# }
|
||||||
|
|
||||||
if (-not [System.String]::IsNullOrWhiteSpace($Mode)) {
|
if (-not [System.String]::IsNullOrWhiteSpace($Mode)) {
|
||||||
$PSBoundParameters.Mode = switch ($Mode) {
|
$PSBoundParameters.Mode = switch ($Mode) {
|
||||||
'Access' {
|
'Access' {
|
||||||
100
|
100
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
'Tagged' {
|
'Tagged' {
|
||||||
200
|
200
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
'Tagged All' {
|
'Tagged All' {
|
||||||
300
|
300
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
default {
|
default {
|
||||||
$_
|
$_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interfaces'))
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interfaces'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
|
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
|
||||||
}
|
}
|
||||||
|
|
@ -1,50 +1,67 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/23/2020 12:10
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Add-NetboxDCIMInterfaceConnection.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function Add-NetboxDCIMInterfaceConnection {
|
function Add-NetboxDCIMInterfaceConnection {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Create a new connection between two interfaces
|
Create a new connection between two interfaces
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Create a new connection between two interfaces
|
Create a new connection between two interfaces
|
||||||
|
|
||||||
.PARAMETER Connection_Status
|
.PARAMETER Connection_Status
|
||||||
Is it connected or planned?
|
Is it connected or planned?
|
||||||
|
|
||||||
.PARAMETER Interface_A
|
.PARAMETER Interface_A
|
||||||
Database ID of interface A
|
Database ID of interface A
|
||||||
|
|
||||||
.PARAMETER Interface_B
|
.PARAMETER Interface_B
|
||||||
Database ID of interface B
|
Database ID of interface B
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> Add-NetboxDCIMInterfaceConnection -Interface_A $value1 -Interface_B $value2
|
PS C:\> Add-NetboxDCIMInterfaceConnection -Interface_A $value1 -Interface_B $value2
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Additional information about the function.
|
Additional information about the function.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
[OutputType([pscustomobject])]
|
[OutputType([pscustomobject])]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[object]$Connection_Status,
|
[object]$Connection_Status,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[uint64]$Interface_A,
|
[uint16]$Interface_A,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[uint64]$Interface_B
|
[uint16]$Interface_B
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if ($null -ne $Connection_Status) {
|
||||||
|
$PSBoundParameters.Connection_Status = ValidateDCIMChoice -ProvidedValue $Connection_Status -InterfaceConnectionStatus
|
||||||
|
}
|
||||||
|
|
||||||
# Verify if both Interfaces exist
|
# Verify if both Interfaces exist
|
||||||
Get-NetboxDCIMInterface -Id $Interface_A -ErrorAction Stop | Out-null
|
$I_A = Get-NetboxDCIMInterface -Id $Interface_A -ErrorAction Stop
|
||||||
Get-NetboxDCIMInterface -Id $Interface_B -ErrorAction Stop | Out-null
|
$I_B = Get-NetboxDCIMInterface -Id $Interface_B -ErrorAction Stop
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interface-connections'))
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interface-connections'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
|
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
|
||||||
}
|
}
|
||||||
|
|
@ -1,46 +1,61 @@
|
||||||
function Get-NetboxDCIMInterface {
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/23/2020 12:09
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Get-NetboxDCIMInterface.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
|
function Get-NetboxDCIMInterface {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
[OutputType([pscustomobject])]
|
[OutputType([pscustomobject])]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[uint16]$Limit,
|
[uint16]$Limit,
|
||||||
|
|
||||||
[uint16]$Offset,
|
[uint16]$Offset,
|
||||||
|
|
||||||
[Parameter(ValueFromPipelineByPropertyName = $true)]
|
[Parameter(ValueFromPipelineByPropertyName = $true)]
|
||||||
[uint64]$Id,
|
[uint16]$Id,
|
||||||
|
|
||||||
[uint64]$Name,
|
[uint16]$Name,
|
||||||
|
|
||||||
[object]$Form_Factor,
|
[object]$Form_Factor,
|
||||||
|
|
||||||
[bool]$Enabled,
|
[bool]$Enabled,
|
||||||
|
|
||||||
[uint16]$MTU,
|
[uint16]$MTU,
|
||||||
|
|
||||||
[bool]$MGMT_Only,
|
[bool]$MGMT_Only,
|
||||||
|
|
||||||
[string]$Device,
|
[string]$Device,
|
||||||
|
|
||||||
[uint64]$Device_Id,
|
[uint16]$Device_Id,
|
||||||
|
|
||||||
[ValidateSet('virtual', 'bridge', 'lag', '100base-tx', '1000base-t', '2.5gbase-t', '5gbase-t', '10gbase-t', '10gbase-cx4', '1000base-x-gbic', '1000base-x-sfp', '10gbase-x-sfpp', '10gbase-x-xfp', '10gbase-x-xenpak', '10gbase-x-x2', '25gbase-x-sfp28', '50gbase-x-sfp56', '40gbase-x-qsfpp', '50gbase-x-sfp28', '100gbase-x-cfp', '100gbase-x-cfp2', '200gbase-x-cfp2', '100gbase-x-cfp4', '100gbase-x-cpak', '100gbase-x-qsfp28', '200gbase-x-qsfp56', '400gbase-x-qsfpdd', '400gbase-x-osfp', '1000base-kx', '10gbase-kr', '10gbase-kx4', '25gbase-kr', '40gbase-kr4', '50gbase-kr', '100gbase-kp4', '100gbase-kr2', '100gbase-kr4', 'ieee802.11a', 'ieee802.11g', 'ieee802.11n', 'ieee802.11ac', 'ieee802.11ad', 'ieee802.11ax', 'ieee802.11ay', 'ieee802.15.1', 'other-wireless', 'gsm', 'cdma', 'lte', 'sonet-oc3', 'sonet-oc12', 'sonet-oc48', 'sonet-oc192', 'sonet-oc768', 'sonet-oc1920', 'sonet-oc3840', '1gfc-sfp', '2gfc-sfp', '4gfc-sfp', '8gfc-sfpp', '16gfc-sfpp', '32gfc-sfp28', '64gfc-qsfpp', '128gfc-qsfp28', 'infiniband-sdr', 'infiniband-ddr', 'infiniband-qdr', 'infiniband-fdr10', 'infiniband-fdr', 'infiniband-edr', 'infiniband-hdr', 'infiniband-ndr', 'infiniband-xdr', 't1', 'e1', 't3', 'e3', 'xdsl', 'docsis', 'gpon', 'xg-pon', 'xgs-pon', 'ng-pon2', 'epon', '10g-epon', 'cisco-stackwise', 'cisco-stackwise-plus', 'cisco-flexstack', 'cisco-flexstack-plus', 'cisco-stackwise-80', 'cisco-stackwise-160', 'cisco-stackwise-320', 'cisco-stackwise-480', 'juniper-vcp', 'extreme-summitstack', 'extreme-summitstack-128', 'extreme-summitstack-256', 'extreme-summitstack-512', 'other', IgnoreCase = $true)]
|
[uint16]$Type,
|
||||||
[string]$Type,
|
|
||||||
|
[uint16]$LAG_Id,
|
||||||
[uint64]$LAG_Id,
|
|
||||||
|
|
||||||
[string]$MAC_Address,
|
[string]$MAC_Address,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
process {
|
if ($null -ne $Form_Factor) {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interfaces'))
|
$PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interfaces'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
}
|
}
|
||||||
|
|
@ -1,29 +1,46 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/23/2020 12:10
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Get-NetboxDCIMInterfaceConnection.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxDCIMInterfaceConnection {
|
function Get-NetboxDCIMInterfaceConnection {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
[OutputType([pscustomobject])]
|
[OutputType([pscustomobject])]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[uint16]$Limit,
|
[uint16]$Limit,
|
||||||
|
|
||||||
[uint16]$Offset,
|
[uint16]$Offset,
|
||||||
|
|
||||||
[uint64]$Id,
|
[uint16]$Id,
|
||||||
|
|
||||||
[object]$Connection_Status,
|
[object]$Connection_Status,
|
||||||
|
|
||||||
[uint64]$Site,
|
[uint16]$Site,
|
||||||
|
|
||||||
[uint64]$Device,
|
[uint16]$Device,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if ($null -ne $Connection_Status) {
|
||||||
|
$PSBoundParameters.Connection_Status = ValidateDCIMChoice -ProvidedValue $Connection_Status -InterfaceConnectionStatus
|
||||||
|
}
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interface-connections'))
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interface-connections'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
}
|
}
|
||||||
|
|
@ -1,54 +1,68 @@
|
||||||
function Remove-NetboxDCIMInterface {
|
<#
|
||||||
<#
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/23/2020 12:11
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Remove-NetboxDCIMInterface.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
|
function Remove-NetboxDCIMInterface {
|
||||||
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Removes an interface
|
Removes an interface
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Removes an interface by ID from a device
|
Removes an interface by ID from a device
|
||||||
|
|
||||||
.PARAMETER Id
|
.PARAMETER Id
|
||||||
A description of the Id parameter.
|
A description of the Id parameter.
|
||||||
|
|
||||||
.PARAMETER Force
|
.PARAMETER Force
|
||||||
A description of the Force parameter.
|
A description of the Force parameter.
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> Remove-NetboxDCIMInterface -Id $value1
|
PS C:\> Remove-NetboxDCIMInterface -Id $value1
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Additional information about the function.
|
Additional information about the function.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding(ConfirmImpact = 'High',
|
[CmdletBinding(ConfirmImpact = 'High',
|
||||||
SupportsShouldProcess = $true)]
|
SupportsShouldProcess = $true)]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true,
|
[Parameter(Mandatory = $true,
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[uint64[]]$Id,
|
[uint16[]]$Id,
|
||||||
|
|
||||||
[switch]$Force
|
[switch]$Force
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
foreach ($InterfaceId in $Id) {
|
foreach ($InterfaceId in $Id) {
|
||||||
$CurrentInterface = Get-NetboxDCIMInterface -Id $InterfaceId -ErrorAction Stop
|
$CurrentInterface = Get-NetboxDCIMInterface -Id $InterfaceId -ErrorAction Stop
|
||||||
|
|
||||||
if ($Force -or $pscmdlet.ShouldProcess("Name: $($CurrentInterface.Name) | ID: $($CurrentInterface.Id)", "Remove")) {
|
if ($Force -or $pscmdlet.ShouldProcess("Name: $($CurrentInterface.Name) | ID: $($CurrentInterface.Id)", "Remove")) {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interfaces', $CurrentInterface.Id))
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interfaces', $CurrentInterface.Id))
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $Segments
|
$URI = BuildNewURI -Segments $Segments
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Method DELETE
|
InvokeNetboxRequest -URI $URI -Method DELETE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
end {
|
end {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,17 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/23/2020 12:12
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Remove-NetboxDCIMInterfaceConnection.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function Remove-NetboxDCIMInterfaceConnection {
|
function Remove-NetboxDCIMInterfaceConnection {
|
||||||
[CmdletBinding(ConfirmImpact = 'High',
|
[CmdletBinding(ConfirmImpact = 'High',
|
||||||
SupportsShouldProcess = $true)]
|
SupportsShouldProcess = $true)]
|
||||||
|
|
@ -7,32 +20,32 @@ function Remove-NetboxDCIMInterfaceConnection {
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true,
|
[Parameter(Mandatory = $true,
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[uint64[]]$Id,
|
[uint16[]]$Id,
|
||||||
|
|
||||||
[switch]$Force
|
[switch]$Force
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
foreach ($ConnectionID in $Id) {
|
foreach ($ConnectionID in $Id) {
|
||||||
$CurrentConnection = Get-NetboxDCIMInterfaceConnection -Id $ConnectionID -ErrorAction Stop
|
$CurrentConnection = Get-NetboxDCIMInterfaceConnection -Id $ConnectionID -ErrorAction Stop
|
||||||
|
|
||||||
if ($Force -or $pscmdlet.ShouldProcess("Connection ID $($ConnectionID.Id)", "REMOVE")) {
|
if ($Force -or $pscmdlet.ShouldProcess("Connection ID $($ConnectionID.Id)", "REMOVE")) {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interface-connections', $CurrentConnection.Id))
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interface-connections', $CurrentConnection.Id))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Method DELETE
|
InvokeNetboxRequest -URI $URI -Method DELETE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
end {
|
end {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,88 +1,98 @@
|
||||||
function Set-NetboxDCIMInterface {
|
<#
|
||||||
[CmdletBinding(ConfirmImpact = 'Medium',
|
.NOTES
|
||||||
SupportsShouldProcess = $true)]
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/23/2020 12:11
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Set-NetboxDCIMInterface.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
|
function Set-NetboxDCIMInterface {
|
||||||
|
[CmdletBinding()]
|
||||||
[OutputType([pscustomobject])]
|
[OutputType([pscustomobject])]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true,
|
[Parameter(Mandatory = $true,
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[uint64[]]$Id,
|
[uint16[]]$Id,
|
||||||
|
|
||||||
[uint64]$Device,
|
[uint16]$Device,
|
||||||
|
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[bool]$Enabled,
|
[bool]$Enabled,
|
||||||
|
|
||||||
[object]$Form_Factor,
|
[object]$Form_Factor,
|
||||||
|
|
||||||
[ValidateSet('virtual', 'bridge', 'lag', '100base-tx', '1000base-t', '2.5gbase-t', '5gbase-t', '10gbase-t', '10gbase-cx4', '1000base-x-gbic', '1000base-x-sfp', '10gbase-x-sfpp', '10gbase-x-xfp', '10gbase-x-xenpak', '10gbase-x-x2', '25gbase-x-sfp28', '50gbase-x-sfp56', '40gbase-x-qsfpp', '50gbase-x-sfp28', '100gbase-x-cfp', '100gbase-x-cfp2', '200gbase-x-cfp2', '100gbase-x-cfp4', '100gbase-x-cpak', '100gbase-x-qsfp28', '200gbase-x-qsfp56', '400gbase-x-qsfpdd', '400gbase-x-osfp', '1000base-kx', '10gbase-kr', '10gbase-kx4', '25gbase-kr', '40gbase-kr4', '50gbase-kr', '100gbase-kp4', '100gbase-kr2', '100gbase-kr4', 'ieee802.11a', 'ieee802.11g', 'ieee802.11n', 'ieee802.11ac', 'ieee802.11ad', 'ieee802.11ax', 'ieee802.11ay', 'ieee802.15.1', 'other-wireless', 'gsm', 'cdma', 'lte', 'sonet-oc3', 'sonet-oc12', 'sonet-oc48', 'sonet-oc192', 'sonet-oc768', 'sonet-oc1920', 'sonet-oc3840', '1gfc-sfp', '2gfc-sfp', '4gfc-sfp', '8gfc-sfpp', '16gfc-sfpp', '32gfc-sfp28', '64gfc-qsfpp', '128gfc-qsfp28', 'infiniband-sdr', 'infiniband-ddr', 'infiniband-qdr', 'infiniband-fdr10', 'infiniband-fdr', 'infiniband-edr', 'infiniband-hdr', 'infiniband-ndr', 'infiniband-xdr', 't1', 'e1', 't3', 'e3', 'xdsl', 'docsis', 'gpon', 'xg-pon', 'xgs-pon', 'ng-pon2', 'epon', '10g-epon', 'cisco-stackwise', 'cisco-stackwise-plus', 'cisco-flexstack', 'cisco-flexstack-plus', 'cisco-stackwise-80', 'cisco-stackwise-160', 'cisco-stackwise-320', 'cisco-stackwise-480', 'juniper-vcp', 'extreme-summitstack', 'extreme-summitstack-128', 'extreme-summitstack-256', 'extreme-summitstack-512', 'other', IgnoreCase = $true)]
|
|
||||||
[string]$Type,
|
|
||||||
|
|
||||||
[uint16]$MTU,
|
[uint16]$MTU,
|
||||||
|
|
||||||
[string]$MAC_Address,
|
[string]$MAC_Address,
|
||||||
|
|
||||||
[bool]$MGMT_Only,
|
[bool]$MGMT_Only,
|
||||||
|
|
||||||
[uint64]$LAG,
|
[uint16]$LAG,
|
||||||
|
|
||||||
[string]$Description,
|
[string]$Description,
|
||||||
|
|
||||||
[ValidateSet('Access', 'Tagged', 'Tagged All', '100', '200', '300', IgnoreCase = $true)]
|
[ValidateSet('Access', 'Tagged', 'Tagged All', '100', '200', '300', IgnoreCase = $true)]
|
||||||
[string]$Mode,
|
[string]$Mode,
|
||||||
|
|
||||||
[ValidateRange(1, 4094)]
|
[ValidateRange(1, 4094)]
|
||||||
[uint16]$Untagged_VLAN,
|
[uint16]$Untagged_VLAN,
|
||||||
|
|
||||||
[ValidateRange(1, 4094)]
|
[ValidateRange(1, 4094)]
|
||||||
[uint16[]]$Tagged_VLANs,
|
[uint16[]]$Tagged_VLANs
|
||||||
|
|
||||||
[switch]$Force
|
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
|
# if ($null -ne $Form_Factor) {
|
||||||
|
# $PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
|
||||||
|
# }
|
||||||
|
|
||||||
if (-not [System.String]::IsNullOrWhiteSpace($Mode)) {
|
if (-not [System.String]::IsNullOrWhiteSpace($Mode)) {
|
||||||
$PSBoundParameters.Mode = switch ($Mode) {
|
$PSBoundParameters.Mode = switch ($Mode) {
|
||||||
'Access' {
|
'Access' {
|
||||||
100
|
100
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
'Tagged' {
|
'Tagged' {
|
||||||
200
|
200
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
'Tagged All' {
|
'Tagged All' {
|
||||||
300
|
300
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
default {
|
default {
|
||||||
$_
|
$_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
foreach ($InterfaceId in $Id) {
|
foreach ($InterfaceId in $Id) {
|
||||||
$CurrentInterface = Get-NetboxDCIMInterface -Id $InterfaceId -ErrorAction Stop
|
$CurrentInterface = Get-NetboxDCIMInterface -Id $InterfaceId -ErrorAction Stop
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interfaces', $CurrentInterface.Id))
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interfaces', $CurrentInterface.Id))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $Segments
|
$URI = BuildNewURI -Segments $Segments
|
||||||
|
|
||||||
if ($Force -or $pscmdlet.ShouldProcess("Interface ID $($CurrentInterface.Id)", "Set")) {
|
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
|
||||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
end {
|
end {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,75 +1,92 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/23/2020 12:11
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Set-NetboxDCIMInterfaceConnection.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function Set-NetboxDCIMInterfaceConnection {
|
function Set-NetboxDCIMInterfaceConnection {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Update an interface connection
|
Update an interface connection
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Update an interface connection
|
Update an interface connection
|
||||||
|
|
||||||
.PARAMETER Id
|
.PARAMETER Id
|
||||||
A description of the Id parameter.
|
A description of the Id parameter.
|
||||||
|
|
||||||
.PARAMETER Connection_Status
|
.PARAMETER Connection_Status
|
||||||
A description of the Connection_Status parameter.
|
A description of the Connection_Status parameter.
|
||||||
|
|
||||||
.PARAMETER Interface_A
|
.PARAMETER Interface_A
|
||||||
A description of the Interface_A parameter.
|
A description of the Interface_A parameter.
|
||||||
|
|
||||||
.PARAMETER Interface_B
|
.PARAMETER Interface_B
|
||||||
A description of the Interface_B parameter.
|
A description of the Interface_B parameter.
|
||||||
|
|
||||||
.PARAMETER Force
|
.PARAMETER Force
|
||||||
A description of the Force parameter.
|
A description of the Force parameter.
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> Set-NetboxDCIMInterfaceConnection -Id $value1
|
PS C:\> Set-NetboxDCIMInterfaceConnection -Id $value1
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Additional information about the function.
|
Additional information about the function.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding(ConfirmImpact = 'Medium',
|
[CmdletBinding(ConfirmImpact = 'Medium',
|
||||||
SupportsShouldProcess = $true)]
|
SupportsShouldProcess = $true)]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true,
|
[Parameter(Mandatory = $true,
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[uint64[]]$Id,
|
[uint16[]]$Id,
|
||||||
|
|
||||||
[object]$Connection_Status,
|
[object]$Connection_Status,
|
||||||
|
|
||||||
[uint64]$Interface_A,
|
[uint16]$Interface_A,
|
||||||
|
|
||||||
[uint64]$Interface_B,
|
[uint16]$Interface_B,
|
||||||
|
|
||||||
[switch]$Force
|
[switch]$Force
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
|
# if ($null -ne $Connection_Status) {
|
||||||
|
# $PSBoundParameters.Connection_Status = ValidateDCIMChoice -ProvidedValue $Connection_Status -InterfaceConnectionStatus
|
||||||
|
# }
|
||||||
|
|
||||||
if ((@($ID).Count -gt 1) -and ($Interface_A -or $Interface_B)) {
|
if ((@($ID).Count -gt 1) -and ($Interface_A -or $Interface_B)) {
|
||||||
throw "Cannot set multiple connections to the same interface"
|
throw "Cannot set multiple connections to the same interface"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
foreach ($ConnectionID in $Id) {
|
foreach ($ConnectionID in $Id) {
|
||||||
$CurrentConnection = Get-NetboxDCIMInterfaceConnection -Id $ConnectionID -ErrorAction Stop
|
$CurrentConnection = Get-NetboxDCIMInterfaceConnection -Id $ConnectionID -ErrorAction Stop
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interface-connections', $CurrentConnection.Id))
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interface-connections', $CurrentConnection.Id))
|
||||||
|
|
||||||
if ($Force -or $pscmdlet.ShouldProcess("Connection ID $($CurrentConnection.Id)", "Set")) {
|
if ($Force -or $pscmdlet.ShouldProcess("Connection ID $($CurrentConnection.Id)", "Set")) {
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
|
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
end {
|
end {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
function Add-NetboxDCIMRearPort {
|
|
||||||
[CmdletBinding()]
|
|
||||||
[OutputType([pscustomobject])]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[uint64]$Device,
|
|
||||||
|
|
||||||
[uint64]$Module,
|
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[string]$Name,
|
|
||||||
|
|
||||||
[string]$Label,
|
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[string]$Type,
|
|
||||||
|
|
||||||
[ValidatePattern('^[0-9a-f]{6}$')]
|
|
||||||
[string]$Color,
|
|
||||||
|
|
||||||
[uint16]$Positions = 1,
|
|
||||||
|
|
||||||
[string]$Description,
|
|
||||||
|
|
||||||
[bool]$Mark_Connected,
|
|
||||||
|
|
||||||
[uint16[]]$Tags
|
|
||||||
)
|
|
||||||
|
|
||||||
begin {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
process {
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'rear-ports'))
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
|
|
||||||
}
|
|
||||||
|
|
||||||
end {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
function Get-NetboxDCIMRearPort {
|
|
||||||
[CmdletBinding()]
|
|
||||||
[OutputType([pscustomobject])]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[uint16]$Limit,
|
|
||||||
|
|
||||||
[uint16]$Offset,
|
|
||||||
|
|
||||||
[Parameter(ValueFromPipelineByPropertyName = $true)]
|
|
||||||
[uint64]$Id,
|
|
||||||
|
|
||||||
[string]$Name,
|
|
||||||
|
|
||||||
[string]$Device,
|
|
||||||
|
|
||||||
[uint64]$Device_Id,
|
|
||||||
|
|
||||||
[string]$Type,
|
|
||||||
|
|
||||||
[switch]$Raw
|
|
||||||
)
|
|
||||||
|
|
||||||
process {
|
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'rear-ports'))
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
function Remove-NetboxDCIMRearPort {
|
|
||||||
|
|
||||||
[CmdletBinding(ConfirmImpact = 'High',
|
|
||||||
SupportsShouldProcess = $true)]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[Parameter(Mandatory = $true,
|
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
|
||||||
[uint64[]]$Id,
|
|
||||||
|
|
||||||
[switch]$Force
|
|
||||||
)
|
|
||||||
|
|
||||||
begin {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
process {
|
|
||||||
foreach ($RearPortID in $Id) {
|
|
||||||
$CurrentPort = Get-NetboxDCIMRearPort -Id $RearPortID -ErrorAction Stop
|
|
||||||
|
|
||||||
if ($Force -or $pscmdlet.ShouldProcess("Name: $($CurrentPort.Name) | ID: $($CurrentPort.Id)", "Remove")) {
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'rear-ports', $CurrentPort.Id))
|
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $Segments
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Method DELETE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
end {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,59 +0,0 @@
|
||||||
|
|
||||||
function Set-NetboxDCIMRearPort {
|
|
||||||
[CmdletBinding(ConfirmImpact = 'Medium',
|
|
||||||
SupportsShouldProcess = $true)]
|
|
||||||
[OutputType([pscustomobject])]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[Parameter(Mandatory = $true,
|
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
|
||||||
[uint64[]]$Id,
|
|
||||||
|
|
||||||
[uint64]$Device,
|
|
||||||
|
|
||||||
[uint64]$Module,
|
|
||||||
|
|
||||||
[string]$Name,
|
|
||||||
|
|
||||||
[string]$Label,
|
|
||||||
|
|
||||||
[string]$Type,
|
|
||||||
|
|
||||||
[ValidatePattern('^[0-9a-f]{6}$')]
|
|
||||||
[string]$Color,
|
|
||||||
|
|
||||||
[uint16]$Positions,
|
|
||||||
|
|
||||||
[string]$Description,
|
|
||||||
|
|
||||||
[bool]$Mark_Connected,
|
|
||||||
|
|
||||||
[uint16[]]$Tags,
|
|
||||||
|
|
||||||
[switch]$Force
|
|
||||||
)
|
|
||||||
|
|
||||||
begin {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
process {
|
|
||||||
foreach ($RearPortID in $Id) {
|
|
||||||
$CurrentPort = Get-NetboxDCIMRearPort -Id $RearPortID -ErrorAction Stop
|
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'rear-ports', $CurrentPort.Id))
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $Segments
|
|
||||||
|
|
||||||
if ($Force -or $pscmdlet.ShouldProcess("Rear Port ID $($CurrentPort.Id)", "Set")) {
|
|
||||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
end {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,95 +1,108 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.181
|
||||||
|
Created on: 2020-10-02 15:52
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Get-NetboxDCIMSite.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxDCIMSite {
|
function Get-NetboxDCIMSite {
|
||||||
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
[CmdletBinding()]
|
||||||
[OutputType([pscustomobject])]
|
[OutputType([pscustomobject])]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(ParameterSetName = 'ByID', ValueFromPipelineByPropertyName = $true)]
|
[Parameter(ParameterSetName = 'ByID', ValueFromPipelineByPropertyName = $true)]
|
||||||
[uint64]$Id,
|
[uint32]$Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Query,
|
[string]$Query,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Slug,
|
[string]$Slug,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Facility,
|
[string]$Facility,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint64]$ASN,
|
[uint32]$ASN,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[decimal]$Latitude,
|
[decimal]$Latitude,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[decimal]$Longitude,
|
[decimal]$Longitude,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Contact_Name,
|
[string]$Contact_Name,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Contact_Phone,
|
[string]$Contact_Phone,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Contact_Email,
|
[string]$Contact_Email,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint64]$Tenant_Group_ID,
|
[uint32]$Tenant_Group_ID,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Tenant_Group,
|
[string]$Tenant_Group,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint64]$Tenant_ID,
|
[uint32]$Tenant_ID,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Tenant,
|
[string]$Tenant,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Status,
|
[string]$Status,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint64]$Region_ID,
|
[uint32]$Region_ID,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Region,
|
[string]$Region,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint16]$Limit,
|
[uint16]$Limit,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint16]$Offset,
|
[uint16]$Offset,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
process {
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
switch ($PSCmdlet.ParameterSetName) {
|
'ById' {
|
||||||
'ById' {
|
foreach ($Site_ID in $ID) {
|
||||||
foreach ($Site_ID in $ID) {
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'sites', $Site_Id))
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'sites', $Site_Id))
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName "Id"
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName "Id"
|
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
default {
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'sites'))
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'sites'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,86 +0,0 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.181
|
|
||||||
Created on: 2020-10-02 15:52
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: New-NetboxDCIMSite.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function New-NetboxDCIMSite {
|
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Create a new Site to Netbox
|
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
Create a new Site to Netbox
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
New-NetboxDCIMSite -name MySite
|
|
||||||
|
|
||||||
Add new Site MySite on Netbox
|
|
||||||
|
|
||||||
#>
|
|
||||||
|
|
||||||
[CmdletBinding(ConfirmImpact = 'Low',
|
|
||||||
SupportsShouldProcess = $true)]
|
|
||||||
[OutputType([pscustomobject])]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[string]$Name,
|
|
||||||
|
|
||||||
[string]$Slug,
|
|
||||||
|
|
||||||
[string]$Facility,
|
|
||||||
|
|
||||||
[uint64]$ASN,
|
|
||||||
|
|
||||||
[decimal]$Latitude,
|
|
||||||
|
|
||||||
[decimal]$Longitude,
|
|
||||||
|
|
||||||
[string]$Contact_Name,
|
|
||||||
|
|
||||||
[string]$Contact_Phone,
|
|
||||||
|
|
||||||
[string]$Contact_Email,
|
|
||||||
|
|
||||||
[uint64]$Tenant_Group,
|
|
||||||
|
|
||||||
[uint64]$Tenant,
|
|
||||||
|
|
||||||
[string]$Status,
|
|
||||||
|
|
||||||
[uint64]$Region,
|
|
||||||
|
|
||||||
[string]$Description,
|
|
||||||
|
|
||||||
[string]$Comments,
|
|
||||||
|
|
||||||
[switch]$Raw
|
|
||||||
)
|
|
||||||
|
|
||||||
process {
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'sites'))
|
|
||||||
$Method = 'POST'
|
|
||||||
|
|
||||||
if (-not $PSBoundParameters.ContainsKey('slug')) {
|
|
||||||
$PSBoundParameters.Add('slug', $name)
|
|
||||||
}
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
|
||||||
|
|
||||||
if ($PSCmdlet.ShouldProcess($name, 'Create new Site')) {
|
|
||||||
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,64 +0,0 @@
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.181
|
|
||||||
Created on: 2020-10-02 15:52
|
|
||||||
Created by: Claussen
|
|
||||||
Organization: NEOnet
|
|
||||||
Filename: New-NetboxDCIMSite.ps1
|
|
||||||
===========================================================================
|
|
||||||
.DESCRIPTION
|
|
||||||
A description of the file.
|
|
||||||
#>
|
|
||||||
|
|
||||||
|
|
||||||
function Remove-NetboxDCIMSite {
|
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Remove a Site
|
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
Remove a DCIM Site from Netbox
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
Remove-NetboxDCIMSite -Id 1
|
|
||||||
|
|
||||||
Remove DCM Site with id 1
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
Get-NetboxDCIMSite -name My Site | Remove-NetboxDCIMSite -confirm:$false
|
|
||||||
|
|
||||||
Remove DCM Site with name My Site without confirmation
|
|
||||||
|
|
||||||
#>
|
|
||||||
|
|
||||||
[CmdletBinding(ConfirmImpact = 'High',
|
|
||||||
SupportsShouldProcess = $true)]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[Parameter(Mandatory = $true,
|
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
|
||||||
[uint]$Id
|
|
||||||
|
|
||||||
)
|
|
||||||
|
|
||||||
begin {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
process {
|
|
||||||
$CurrentSite = Get-NetboxDCIMSite -Id $Id -ErrorAction Stop
|
|
||||||
|
|
||||||
if ($pscmdlet.ShouldProcess("$($CurrentSite.Name)/$($CurrentSite.Id)", "Remove Site")) {
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'sites', $CurrentSite.Id))
|
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $Segments
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Method DELETE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
end {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
|
|
||||||
function Get-NetboxTag {
|
|
||||||
[CmdletBinding()]
|
|
||||||
[OutputType([pscustomobject])]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[Parameter(ValueFromPipelineByPropertyName = $true)]
|
|
||||||
[uint64]$Id,
|
|
||||||
|
|
||||||
[string]$Name,
|
|
||||||
|
|
||||||
[string]$Slug,
|
|
||||||
|
|
||||||
[uint16]$Limit,
|
|
||||||
|
|
||||||
[uint16]$Offset,
|
|
||||||
|
|
||||||
[switch]$Raw
|
|
||||||
)
|
|
||||||
|
|
||||||
process {
|
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('extras', 'tags'))
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,79 +1,92 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/26/2020 14:22
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: BuildNewURI.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function BuildNewURI {
|
function BuildNewURI {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Create a new URI for Netbox
|
Create a new URI for Netbox
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Internal function used to build a URIBuilder object.
|
Internal function used to build a URIBuilder object.
|
||||||
|
|
||||||
.PARAMETER Hostname
|
.PARAMETER Hostname
|
||||||
Hostname of the Netbox API
|
Hostname of the Netbox API
|
||||||
|
|
||||||
.PARAMETER Segments
|
.PARAMETER Segments
|
||||||
Array of strings for each segment in the URL path
|
Array of strings for each segment in the URL path
|
||||||
|
|
||||||
.PARAMETER Parameters
|
.PARAMETER Parameters
|
||||||
Hashtable of query parameters to include
|
Hashtable of query parameters to include
|
||||||
|
|
||||||
.PARAMETER HTTPS
|
.PARAMETER HTTPS
|
||||||
Whether to use HTTPS or HTTP
|
Whether to use HTTPS or HTTP
|
||||||
|
|
||||||
.PARAMETER Port
|
.PARAMETER Port
|
||||||
A description of the Port parameter.
|
A description of the Port parameter.
|
||||||
|
|
||||||
.PARAMETER APIInfo
|
.PARAMETER APIInfo
|
||||||
A description of the APIInfo parameter.
|
A description of the APIInfo parameter.
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> BuildNewURI
|
PS C:\> BuildNewURI
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Additional information about the function.
|
Additional information about the function.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
[OutputType([System.UriBuilder])]
|
[OutputType([System.UriBuilder])]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $false)]
|
[Parameter(Mandatory = $false)]
|
||||||
[string[]]$Segments,
|
[string[]]$Segments,
|
||||||
|
|
||||||
[Parameter(Mandatory = $false)]
|
[Parameter(Mandatory = $false)]
|
||||||
[hashtable]$Parameters,
|
[hashtable]$Parameters,
|
||||||
|
|
||||||
[switch]$SkipConnectedCheck
|
[switch]$SkipConnectedCheck
|
||||||
)
|
)
|
||||||
|
|
||||||
Write-Verbose "Building URI"
|
Write-Verbose "Building URI"
|
||||||
|
|
||||||
if (-not $SkipConnectedCheck) {
|
if (-not $SkipConnectedCheck) {
|
||||||
# There is no point in continuing if we have not successfully connected to an API
|
# There is no point in continuing if we have not successfully connected to an API
|
||||||
$null = CheckNetboxIsConnected
|
$null = CheckNetboxIsConnected
|
||||||
}
|
}
|
||||||
|
|
||||||
# Begin a URI builder with HTTP/HTTPS and the provided hostname
|
# Begin a URI builder with HTTP/HTTPS and the provided hostname
|
||||||
$uriBuilder = [System.UriBuilder]::new($script:NetboxConfig.HostScheme, $script:NetboxConfig.Hostname, $script:NetboxConfig.HostPort)
|
$uriBuilder = [System.UriBuilder]::new($script:NetboxConfig.HostScheme, $script:NetboxConfig.Hostname, $script:NetboxConfig.HostPort)
|
||||||
|
|
||||||
# Generate the path by trimming excess slashes and whitespace from the $segments[] and joining together
|
# Generate the path by trimming excess slashes and whitespace from the $segments[] and joining together
|
||||||
$uriBuilder.Path = "api/{0}/" -f ($Segments.ForEach({
|
$uriBuilder.Path = "api/{0}/" -f ($Segments.ForEach({
|
||||||
$_.trim('/').trim()
|
$_.trim('/').trim()
|
||||||
}) -join '/')
|
}) -join '/')
|
||||||
|
|
||||||
Write-Verbose " URIPath: $($uriBuilder.Path)"
|
Write-Verbose " URIPath: $($uriBuilder.Path)"
|
||||||
|
|
||||||
if ($parameters) {
|
if ($parameters) {
|
||||||
# Loop through the parameters and use the HttpUtility to create a Query string
|
# Loop through the parameters and use the HttpUtility to create a Query string
|
||||||
[System.Collections.Specialized.NameValueCollection]$URIParams = [System.Web.HttpUtility]::ParseQueryString([String]::Empty)
|
[System.Collections.Specialized.NameValueCollection]$URIParams = [System.Web.HttpUtility]::ParseQueryString([String]::Empty)
|
||||||
|
|
||||||
foreach ($param in $Parameters.GetEnumerator()) {
|
foreach ($param in $Parameters.GetEnumerator()) {
|
||||||
Write-Verbose " Adding URI parameter $($param.Key):$($param.Value)"
|
Write-Verbose " Adding URI parameter $($param.Key):$($param.Value)"
|
||||||
$URIParams[$param.Key] = $param.Value
|
$URIParams[$param.Key] = $param.Value
|
||||||
}
|
}
|
||||||
|
|
||||||
$uriBuilder.Query = $URIParams.ToString()
|
$uriBuilder.Query = $URIParams.ToString()
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Verbose " Completed building URIBuilder"
|
Write-Verbose " Completed building URIBuilder"
|
||||||
# Return the entire UriBuilder object
|
# Return the entire UriBuilder object
|
||||||
$uriBuilder
|
$uriBuilder
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,17 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/26/2020 14:23
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: BuildURIComponents.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function BuildURIComponents {
|
function BuildURIComponents {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
[OutputType([hashtable])]
|
[OutputType([hashtable])]
|
||||||
|
|
@ -6,30 +19,30 @@ function BuildURIComponents {
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[System.Collections.ArrayList]$URISegments,
|
[System.Collections.ArrayList]$URISegments,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[object]$ParametersDictionary,
|
[object]$ParametersDictionary,
|
||||||
|
|
||||||
[string[]]$SkipParameterByName
|
[string[]]$SkipParameterByName
|
||||||
)
|
)
|
||||||
|
|
||||||
Write-Verbose "Building URI components"
|
Write-Verbose "Building URI components"
|
||||||
|
|
||||||
$URIParameters = @{
|
$URIParameters = @{
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($CmdletParameterName in $ParametersDictionary.Keys) {
|
foreach ($CmdletParameterName in $ParametersDictionary.Keys) {
|
||||||
if ($CmdletParameterName -in $script:CommonParameterNames) {
|
if ($CmdletParameterName -in $script:CommonParameterNames) {
|
||||||
# These are common parameters and should not be appended to the URI
|
# These are common parameters and should not be appended to the URI
|
||||||
Write-Debug "Skipping common parameter $CmdletParameterName"
|
Write-Debug "Skipping common parameter $CmdletParameterName"
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($CmdletParameterName -in $SkipParameterByName) {
|
if ($CmdletParameterName -in $SkipParameterByName) {
|
||||||
Write-Debug "Skipping parameter $CmdletParameterName by SkipParameterByName"
|
Write-Debug "Skipping parameter $CmdletParameterName by SkipParameterByName"
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($CmdletParameterName) {
|
switch ($CmdletParameterName) {
|
||||||
"id" {
|
"id" {
|
||||||
# Check if there is one or more values for Id and build a URI or query as appropriate
|
# Check if there is one or more values for Id and build a URI or query as appropriate
|
||||||
|
|
@ -40,26 +53,26 @@ function BuildURIComponents {
|
||||||
Write-Verbose " Adding ID to segments"
|
Write-Verbose " Adding ID to segments"
|
||||||
[void]$uriSegments.Add($ParametersDictionary[$CmdletParameterName])
|
[void]$uriSegments.Add($ParametersDictionary[$CmdletParameterName])
|
||||||
}
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
'Query' {
|
'Query' {
|
||||||
Write-Verbose " Adding query parameter"
|
Write-Verbose " Adding query parameter"
|
||||||
$URIParameters['q'] = $ParametersDictionary[$CmdletParameterName]
|
$URIParameters['q'] = $ParametersDictionary[$CmdletParameterName]
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
'CustomFields' {
|
'CustomFields' {
|
||||||
Write-Verbose " Adding custom field query parameters"
|
Write-Verbose " Adding custom field query parameters"
|
||||||
foreach ($field in $ParametersDictionary[$CmdletParameterName].GetEnumerator()) {
|
foreach ($field in $ParametersDictionary[$CmdletParameterName].GetEnumerator()) {
|
||||||
Write-Verbose " Adding parameter 'cf_$($field.Key) = $($field.Value)"
|
Write-Verbose " Adding parameter 'cf_$($field.Key) = $($field.Value)"
|
||||||
$URIParameters["cf_$($field.Key.ToLower())"] = $field.Value
|
$URIParameters["cf_$($field.Key.ToLower())"] = $field.Value
|
||||||
}
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
default {
|
default {
|
||||||
Write-Verbose " Adding $($CmdletParameterName.ToLower()) parameter"
|
Write-Verbose " Adding $($CmdletParameterName.ToLower()) parameter"
|
||||||
$URIParameters[$CmdletParameterName.ToLower()] = $ParametersDictionary[$CmdletParameterName]
|
$URIParameters[$CmdletParameterName.ToLower()] = $ParametersDictionary[$CmdletParameterName]
|
||||||
|
|
@ -67,7 +80,7 @@ function BuildURIComponents {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return @{
|
return @{
|
||||||
'Segments' = [System.Collections.ArrayList]$URISegments
|
'Segments' = [System.Collections.ArrayList]$URISegments
|
||||||
'Parameters' = $URIParameters
|
'Parameters' = $URIParameters
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,21 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/26/2020 14:22
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: CheckNetboxIsConnected.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function CheckNetboxIsConnected {
|
function CheckNetboxIsConnected {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param ()
|
param ()
|
||||||
|
|
||||||
Write-Verbose "Checking connection status"
|
Write-Verbose "Checking connection status"
|
||||||
if (-not $script:NetboxConfig.Connected) {
|
if (-not $script:NetboxConfig.Connected) {
|
||||||
throw "Not connected to a Netbox API! Please run 'Connect-NetboxAPI'"
|
throw "Not connected to a Netbox API! Please run 'Connect-NetboxAPI'"
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,30 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/26/2020 14:25
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: CreateEnum.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function CreateEnum {
|
function CreateEnum {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[string]$EnumName,
|
[string]$EnumName,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[pscustomobject]$Values,
|
[pscustomobject]$Values,
|
||||||
|
|
||||||
[switch]$PassThru
|
[switch]$PassThru
|
||||||
)
|
)
|
||||||
|
|
||||||
$definition = @"
|
$definition = @"
|
||||||
public enum $EnumName
|
public enum $EnumName
|
||||||
{`n$(foreach ($value in $values) {
|
{`n$(foreach ($value in $values) {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,18 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.181
|
||||||
|
Created on: 2020-11-04 14:23
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Get-ModelDefinition.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function Get-ModelDefinition {
|
function Get-ModelDefinition {
|
||||||
[CmdletBinding(DefaultParameterSetName = 'ByName')]
|
[CmdletBinding(DefaultParameterSetName = 'ByName')]
|
||||||
param
|
param
|
||||||
|
|
@ -6,45 +20,45 @@ function Get-ModelDefinition {
|
||||||
[Parameter(ParameterSetName = 'ByName',
|
[Parameter(ParameterSetName = 'ByName',
|
||||||
Mandatory = $true)]
|
Mandatory = $true)]
|
||||||
[string]$ModelName,
|
[string]$ModelName,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'ByPath',
|
[Parameter(ParameterSetName = 'ByPath',
|
||||||
Mandatory = $true)]
|
Mandatory = $true)]
|
||||||
[string]$URIPath,
|
[string]$URIPath,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'ByPath')]
|
[Parameter(ParameterSetName = 'ByPath')]
|
||||||
[string]$Method = "post"
|
[string]$Method = "post"
|
||||||
)
|
)
|
||||||
|
|
||||||
switch ($PsCmdlet.ParameterSetName) {
|
switch ($PsCmdlet.ParameterSetName) {
|
||||||
'ByName' {
|
'ByName' {
|
||||||
$script:NetboxConfig.APIDefinition.definitions.$ModelName
|
$script:NetboxConfig.APIDefinition.definitions.$ModelName
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
'ByPath' {
|
'ByPath' {
|
||||||
switch ($Method) {
|
switch ($Method) {
|
||||||
"get" {
|
"get" {
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
"post" {
|
"post" {
|
||||||
if (-not $URIPath.StartsWith('/')) {
|
if (-not $URIPath.StartsWith('/')) {
|
||||||
$URIPath = "/$URIPath"
|
$URIPath = "/$URIPath"
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-not $URIPath.EndsWith('/')) {
|
if (-not $URIPath.EndsWith('/')) {
|
||||||
$URIPath = "$URIPath/"
|
$URIPath = "$URIPath/"
|
||||||
}
|
}
|
||||||
|
|
||||||
$ModelName = $script:NetboxConfig.APIDefinition.paths.$URIPath.post.parameters.schema.'$ref'.split('/')[-1]
|
$ModelName = $script:NetboxConfig.APIDefinition.paths.$URIPath.post.parameters.schema.'$ref'.split('/')[-1]
|
||||||
$script:NetboxConfig.APIDefinition.definitions.$ModelName
|
$script:NetboxConfig.APIDefinition.definitions.$ModelName
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,27 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/26/2020 14:23
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: GetNetboxAPIErrorBody.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function GetNetboxAPIErrorBody {
|
function GetNetboxAPIErrorBody {
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[System.Net.HttpWebResponse]$Response
|
[System.Net.HttpWebResponse]$Response
|
||||||
)
|
)
|
||||||
|
|
||||||
# This takes the $Response stream and turns it into a useable object... generally a string.
|
# This takes the $Response stream and turns it into a useable object... generally a string.
|
||||||
# If the body is JSON, you should be able to use ConvertFrom-Json
|
# If the body is JSON, you should be able to use ConvertFrom-Json
|
||||||
|
|
||||||
$reader = New-Object System.IO.StreamReader($Response.GetResponseStream())
|
$reader = New-Object System.IO.StreamReader($Response.GetResponseStream())
|
||||||
$reader.BaseStream.Position = 0
|
$reader.BaseStream.Position = 0
|
||||||
$reader.DiscardBufferedData()
|
$reader.DiscardBufferedData()
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,17 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/26/2020 14:24
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: InvokeNetboxRequest.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function InvokeNetboxRequest {
|
function InvokeNetboxRequest {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,24 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/26/2020 14:25
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: ThrowNetboxRESTError.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function ThrowNetboxRESTError {
|
function ThrowNetboxRESTError {
|
||||||
$uriSegments = [System.Collections.ArrayList]::new(@('fake', 'url'))
|
$uriSegments = [System.Collections.ArrayList]::new(@('fake', 'url'))
|
||||||
|
|
||||||
$URIParameters = @{
|
$URIParameters = @{
|
||||||
}
|
}
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $uriSegments -Parameters $URIParameters
|
$uri = BuildNewURI -Segments $uriSegments -Parameters $URIParameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw
|
InvokeNetboxRequest -URI $uri -Raw
|
||||||
}
|
}
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
[string]$Address,
|
[string]$Address,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'ByID')]
|
[Parameter(ParameterSetName = 'ByID')]
|
||||||
[uint64[]]$Id,
|
[uint32[]]$Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Query,
|
[string]$Query,
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
[object]$Family,
|
[object]$Family,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Parent,
|
[uint32]$Parent,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[byte]$Mask_Length,
|
[byte]$Mask_Length,
|
||||||
|
|
@ -25,28 +25,28 @@
|
||||||
[string]$VRF,
|
[string]$VRF,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint64]$VRF_Id,
|
[uint32]$VRF_Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Tenant,
|
[string]$Tenant,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint64]$Tenant_Id,
|
[uint32]$Tenant_Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Device,
|
[string]$Device,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint64]$Device_ID,
|
[uint32]$Device_ID,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Virtual_Machine,
|
[string]$Virtual_Machine,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint64]$Virtual_Machine_Id,
|
[uint32]$Virtual_Machine_Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint64]$Interface_Id,
|
[uint32]$Interface_Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[object]$Status,
|
[object]$Status,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,17 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/19/2020 11:50
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Get-NetboxIPAMAvailableIP.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxIPAMAvailableIP {
|
function Get-NetboxIPAMAvailableIP {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
|
|
@ -21,14 +34,7 @@ function Get-NetboxIPAMAvailableIP {
|
||||||
A description of the NumberOfIPs parameter.
|
A description of the NumberOfIPs parameter.
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Get-NetboxIPAMAvailableIP -Prefix_ID (Get-NetboxIPAMPrefix -Prefix 192.0.2.0/24).id
|
PS C:\> Get-NetboxIPAMAvaiableIP -Prefix_ID $value1
|
||||||
|
|
||||||
Get (Next) Available IP on the Prefix 192.0.2.0/24
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
Get-NetboxIPAMAvailableIP -Prefix_ID 2 -NumberOfIPs 3
|
|
||||||
|
|
||||||
Get 3 (Next) Available IP on the Prefix 192.0.2.0/24
|
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Additional information about the function.
|
Additional information about the function.
|
||||||
|
|
@ -40,10 +46,10 @@ function Get-NetboxIPAMAvailableIP {
|
||||||
[Parameter(Mandatory = $true,
|
[Parameter(Mandatory = $true,
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[Alias('Id')]
|
[Alias('Id')]
|
||||||
[uint64]$Prefix_ID,
|
[int]$Prefix_ID,
|
||||||
|
|
||||||
[Alias('NumberOfIPs')]
|
[Alias('NumberOfIPs')]
|
||||||
[uint64]$Limit,
|
[int]$Limit,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,17 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/19/2020 11:51
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: New-NetboxIPAMAddress.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function New-NetboxIPAMAddress {
|
function New-NetboxIPAMAddress {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
|
|
@ -37,19 +50,14 @@ function New-NetboxIPAMAddress {
|
||||||
.PARAMETER Dns_name
|
.PARAMETER Dns_name
|
||||||
DNS Name of IP address (example : netbox.example.com)
|
DNS Name of IP address (example : netbox.example.com)
|
||||||
|
|
||||||
.PARAMETER Assigned_Object_Type
|
.PARAMETER Force
|
||||||
Assigned Object Type dcim.interface or virtualization.vminterface
|
Do not prompt for confirmation to create IP.
|
||||||
|
|
||||||
.PARAMETER Assigned_Object_Id
|
|
||||||
Assigned Object ID
|
|
||||||
|
|
||||||
.PARAMETER Raw
|
.PARAMETER Raw
|
||||||
Return raw results from API service
|
Return raw results from API service
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
New-NetboxIPAMAddress -Address 192.0.2.1/32
|
PS C:\> Create-NetboxIPAMAddress
|
||||||
|
|
||||||
Add new IP Address 192.0.2.1/32 with status active
|
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Additional information about the function.
|
Additional information about the function.
|
||||||
|
|
@ -66,26 +74,23 @@ function New-NetboxIPAMAddress {
|
||||||
|
|
||||||
[object]$Status = 'Active',
|
[object]$Status = 'Active',
|
||||||
|
|
||||||
[uint64]$Tenant,
|
[int]$Tenant,
|
||||||
|
|
||||||
[uint64]$VRF,
|
[int]$VRF,
|
||||||
|
|
||||||
[object]$Role,
|
[object]$Role,
|
||||||
|
|
||||||
[uint64]$NAT_Inside,
|
[int]$NAT_Inside,
|
||||||
|
|
||||||
[hashtable]$Custom_Fields,
|
[hashtable]$Custom_Fields,
|
||||||
|
|
||||||
[uint64]$Interface,
|
[int]$Interface,
|
||||||
|
|
||||||
[string]$Description,
|
[string]$Description,
|
||||||
|
|
||||||
[string]$Dns_name,
|
[string]$Dns_name,
|
||||||
|
|
||||||
[ValidateSet('dcim.interface', 'virtualization.vminterface', IgnoreCase = $true)]
|
[switch]$Force,
|
||||||
[string]$Assigned_Object_Type,
|
|
||||||
|
|
||||||
[uint64]$Assigned_Object_Id,
|
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
@ -94,11 +99,22 @@ function New-NetboxIPAMAddress {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
|
||||||
$Method = 'POST'
|
$Method = 'POST'
|
||||||
|
|
||||||
|
# # Value validation
|
||||||
|
# $ModelDefinition = GetModelDefinitionFromURIPath -Segments $Segments -Method $Method
|
||||||
|
# $EnumProperties = GetModelEnumProperties -ModelDefinition $ModelDefinition
|
||||||
|
#
|
||||||
|
# foreach ($Property in $EnumProperties.Keys) {
|
||||||
|
# if ($PSBoundParameters.ContainsKey($Property)) {
|
||||||
|
# Write-Verbose "Validating property [$Property] with value [$($PSBoundParameters.$Property)]"
|
||||||
|
# $PSBoundParameters.$Property = ValidateValue -ModelDefinition $ModelDefinition -Property $Property -ProvidedValue $PSBoundParameters.$Property
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
#
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
if ($PSCmdlet.ShouldProcess($Address, 'Create new IP address')) {
|
if ($Force -or $PSCmdlet.ShouldProcess($Address, 'Create new IP address')) {
|
||||||
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,16 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/19/2020 11:52
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Remove-NetboxIPAMAddress.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
function Remove-NetboxIPAMAddress {
|
function Remove-NetboxIPAMAddress {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
|
|
@ -26,7 +38,7 @@ function Remove-NetboxIPAMAddress {
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true,
|
[Parameter(Mandatory = $true,
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[uint64[]]$Id,
|
[int[]]$Id,
|
||||||
|
|
||||||
[switch]$Force
|
[switch]$Force
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,17 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/19/2020 11:53
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Set-NetboxIPAMAddress.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function Set-NetboxIPAMAddress {
|
function Set-NetboxIPAMAddress {
|
||||||
[CmdletBinding(ConfirmImpact = 'Medium',
|
[CmdletBinding(ConfirmImpact = 'Medium',
|
||||||
SupportsShouldProcess = $true)]
|
SupportsShouldProcess = $true)]
|
||||||
|
|
@ -6,26 +19,26 @@ function Set-NetboxIPAMAddress {
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true,
|
[Parameter(Mandatory = $true,
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[uint64[]]$Id,
|
[int[]]$Id,
|
||||||
|
|
||||||
[string]$Address,
|
[string]$Address,
|
||||||
|
|
||||||
[string]$Status,
|
[string]$Status,
|
||||||
|
|
||||||
[uint64]$Tenant,
|
[int]$Tenant,
|
||||||
|
|
||||||
[uint64]$VRF,
|
[int]$VRF,
|
||||||
|
|
||||||
[object]$Role,
|
[object]$Role,
|
||||||
|
|
||||||
[uint64]$NAT_Inside,
|
[int]$NAT_Inside,
|
||||||
|
|
||||||
[hashtable]$Custom_Fields,
|
[hashtable]$Custom_Fields,
|
||||||
|
|
||||||
[ValidateSet('dcim.interface', 'virtualization.vminterface', IgnoreCase = $true)]
|
[ValidateSet('dcim.interface', 'virtualization.vminterface', IgnoreCase = $true)]
|
||||||
[string]$Assigned_Object_Type,
|
[string]$Assigned_Object_Type,
|
||||||
|
|
||||||
[uint64]$Assigned_Object_Id,
|
[uint16]$Assigned_Object_Id,
|
||||||
|
|
||||||
[string]$Description,
|
[string]$Description,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,65 +1,78 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/19/2020 11:49
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Get-NetboxIPAMAggregate.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxIPAMAggregate {
|
function Get-NetboxIPAMAggregate {
|
||||||
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Query,
|
[string]$Query,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'ByID')]
|
[Parameter(ParameterSetName = 'ByID')]
|
||||||
[uint64[]]$Id,
|
[uint16[]]$Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Prefix,
|
[string]$Prefix,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[object]$Family,
|
[object]$Family,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint64]$RIR_Id,
|
[uint16]$RIR_Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$RIR,
|
[string]$RIR,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[datetime]$Date_Added,
|
[datetime]$Date_Added,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint16]$Limit,
|
[uint16]$Limit,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint16]$Offset,
|
[uint16]$Offset,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
# if ($null -ne $Family) {
|
# if ($null -ne $Family) {
|
||||||
# $PSBoundParameters.Family = ValidateIPAMChoice -ProvidedValue $Family -AggregateFamily
|
# $PSBoundParameters.Family = ValidateIPAMChoice -ProvidedValue $Family -AggregateFamily
|
||||||
# }
|
# }
|
||||||
|
|
||||||
switch ($PSCmdlet.ParameterSetName) {
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
'ById' {
|
'ById' {
|
||||||
foreach ($IP_ID in $Id) {
|
foreach ($IP_ID in $Id) {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'aggregates', $IP_ID))
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'aggregates', $IP_ID))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
default {
|
default {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'aggregates'))
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'aggregates'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,191 +1,204 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/19/2020 11:51
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Get-NetboxIPAMPrefix.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxIPAMPrefix {
|
function Get-NetboxIPAMPrefix {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
A brief description of the Get-NetboxIPAMPrefix function.
|
A brief description of the Get-NetboxIPAMPrefix function.
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
A detailed description of the Get-NetboxIPAMPrefix function.
|
A detailed description of the Get-NetboxIPAMPrefix function.
|
||||||
|
|
||||||
.PARAMETER Query
|
.PARAMETER Query
|
||||||
A description of the Query parameter.
|
A description of the Query parameter.
|
||||||
|
|
||||||
.PARAMETER Id
|
.PARAMETER Id
|
||||||
A description of the Id parameter.
|
A description of the Id parameter.
|
||||||
|
|
||||||
.PARAMETER Limit
|
.PARAMETER Limit
|
||||||
A description of the Limit parameter.
|
A description of the Limit parameter.
|
||||||
|
|
||||||
.PARAMETER Offset
|
.PARAMETER Offset
|
||||||
A description of the Offset parameter.
|
A description of the Offset parameter.
|
||||||
|
|
||||||
.PARAMETER Family
|
.PARAMETER Family
|
||||||
A description of the Family parameter.
|
A description of the Family parameter.
|
||||||
|
|
||||||
.PARAMETER Is_Pool
|
.PARAMETER Is_Pool
|
||||||
A description of the Is_Pool parameter.
|
A description of the Is_Pool parameter.
|
||||||
|
|
||||||
.PARAMETER Within
|
.PARAMETER Within
|
||||||
Should be a CIDR notation prefix such as '10.0.0.0/16'
|
Should be a CIDR notation prefix such as '10.0.0.0/16'
|
||||||
|
|
||||||
.PARAMETER Within_Include
|
.PARAMETER Within_Include
|
||||||
Should be a CIDR notation prefix such as '10.0.0.0/16'
|
Should be a CIDR notation prefix such as '10.0.0.0/16'
|
||||||
|
|
||||||
.PARAMETER Contains
|
.PARAMETER Contains
|
||||||
A description of the Contains parameter.
|
A description of the Contains parameter.
|
||||||
|
|
||||||
.PARAMETER Mask_Length
|
.PARAMETER Mask_Length
|
||||||
CIDR mask length value
|
CIDR mask length value
|
||||||
|
|
||||||
.PARAMETER VRF
|
.PARAMETER VRF
|
||||||
A description of the VRF parameter.
|
A description of the VRF parameter.
|
||||||
|
|
||||||
.PARAMETER VRF_Id
|
.PARAMETER VRF_Id
|
||||||
A description of the VRF_Id parameter.
|
A description of the VRF_Id parameter.
|
||||||
|
|
||||||
.PARAMETER Tenant
|
.PARAMETER Tenant
|
||||||
A description of the Tenant parameter.
|
A description of the Tenant parameter.
|
||||||
|
|
||||||
.PARAMETER Tenant_Id
|
.PARAMETER Tenant_Id
|
||||||
A description of the Tenant_Id parameter.
|
A description of the Tenant_Id parameter.
|
||||||
|
|
||||||
.PARAMETER Site
|
.PARAMETER Site
|
||||||
A description of the Site parameter.
|
A description of the Site parameter.
|
||||||
|
|
||||||
.PARAMETER Site_Id
|
.PARAMETER Site_Id
|
||||||
A description of the Site_Id parameter.
|
A description of the Site_Id parameter.
|
||||||
|
|
||||||
.PARAMETER Vlan_VId
|
.PARAMETER Vlan_VId
|
||||||
A description of the Vlan_VId parameter.
|
A description of the Vlan_VId parameter.
|
||||||
|
|
||||||
.PARAMETER Vlan_Id
|
.PARAMETER Vlan_Id
|
||||||
A description of the Vlan_Id parameter.
|
A description of the Vlan_Id parameter.
|
||||||
|
|
||||||
.PARAMETER Status
|
.PARAMETER Status
|
||||||
A description of the Status parameter.
|
A description of the Status parameter.
|
||||||
|
|
||||||
.PARAMETER Role
|
.PARAMETER Role
|
||||||
A description of the Role parameter.
|
A description of the Role parameter.
|
||||||
|
|
||||||
.PARAMETER Role_Id
|
.PARAMETER Role_Id
|
||||||
A description of the Role_Id parameter.
|
A description of the Role_Id parameter.
|
||||||
|
|
||||||
.PARAMETER Raw
|
.PARAMETER Raw
|
||||||
A description of the Raw parameter.
|
A description of the Raw parameter.
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> Get-NetboxIPAMPrefix
|
PS C:\> Get-NetboxIPAMPrefix
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Additional information about the function.
|
Additional information about the function.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(ParameterSetName = 'Query',
|
[Parameter(ParameterSetName = 'Query',
|
||||||
Position = 0)]
|
Position = 0)]
|
||||||
[string]$Prefix,
|
[string]$Prefix,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Query,
|
[string]$Query,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'ByID')]
|
[Parameter(ParameterSetName = 'ByID')]
|
||||||
[uint64[]]$Id,
|
[uint32[]]$Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[object]$Family,
|
[object]$Family,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[boolean]$Is_Pool,
|
[boolean]$Is_Pool,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Within,
|
[string]$Within,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Within_Include,
|
[string]$Within_Include,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Contains,
|
[string]$Contains,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[ValidateRange(0, 127)]
|
[ValidateRange(0, 127)]
|
||||||
[byte]$Mask_Length,
|
[byte]$Mask_Length,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$VRF,
|
[string]$VRF,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint64]$VRF_Id,
|
[uint32]$VRF_Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Tenant,
|
[string]$Tenant,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint64]$Tenant_Id,
|
[uint32]$Tenant_Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Site,
|
[string]$Site,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint64]$Site_Id,
|
[uint32]$Site_Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Vlan_VId,
|
[string]$Vlan_VId,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint64]$Vlan_Id,
|
[uint32]$Vlan_Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[object]$Status,
|
[object]$Status,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Role,
|
[string]$Role,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint64]$Role_Id,
|
[uint32]$Role_Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint16]$Limit,
|
[uint16]$Limit,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint16]$Offset,
|
[uint16]$Offset,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
# if ($null -ne $Family) {
|
# if ($null -ne $Family) {
|
||||||
# $PSBoundParameters.Family = ValidateIPAMChoice -ProvidedValue $Family -PrefixFamily
|
# $PSBoundParameters.Family = ValidateIPAMChoice -ProvidedValue $Family -PrefixFamily
|
||||||
# }
|
# }
|
||||||
#
|
#
|
||||||
# if ($null -ne $Status) {
|
# if ($null -ne $Status) {
|
||||||
# $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -PrefixStatus
|
# $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -PrefixStatus
|
||||||
# }
|
# }
|
||||||
|
|
||||||
switch ($PSCmdlet.ParameterSetName) {
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
'ById' {
|
'ById' {
|
||||||
foreach ($Prefix_ID in $Id) {
|
foreach ($Prefix_ID in $Id) {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes', $Prefix_ID))
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes', $Prefix_ID))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
}
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
default {
|
default {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes'))
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,50 +1,59 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/19/2020 11:52
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: New-NetboxIPAMPrefix.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function New-NetboxIPAMPrefix {
|
function New-NetboxIPAMPrefix {
|
||||||
[CmdletBinding(ConfirmImpact = 'low',
|
|
||||||
SupportsShouldProcess = $true)]
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[string]$Prefix,
|
[string]$Prefix,
|
||||||
|
|
||||||
[object]$Status = 'Active',
|
[object]$Status = 'Active',
|
||||||
|
|
||||||
[uint64]$Tenant,
|
[uint16]$Tenant,
|
||||||
|
|
||||||
[object]$Role,
|
[object]$Role,
|
||||||
|
|
||||||
[bool]$IsPool,
|
[bool]$IsPool,
|
||||||
|
|
||||||
[string]$Description,
|
[string]$Description,
|
||||||
|
|
||||||
[uint64]$Site,
|
[uint16]$Site,
|
||||||
|
|
||||||
[uint64]$VRF,
|
[uint16]$VRF,
|
||||||
|
|
||||||
[uint64]$VLAN,
|
[uint16]$VLAN,
|
||||||
|
|
||||||
[hashtable]$Custom_Fields,
|
[hashtable]$Custom_Fields,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
# $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -PrefixStatus
|
# $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -PrefixStatus
|
||||||
|
|
||||||
<#
|
<#
|
||||||
# As of 2018/10/18, this does not appear to be a validated IPAM choice
|
# As of 2018/10/18, this does not appear to be a validated IPAM choice
|
||||||
if ($null -ne $Role) {
|
if ($null -ne $Role) {
|
||||||
$PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -PrefixRole
|
$PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -PrefixRole
|
||||||
}
|
}
|
||||||
#>
|
#>
|
||||||
|
|
||||||
$segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes'))
|
$segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $segments -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
if ($PSCmdlet.ShouldProcess($Prefix, 'Create new Prefix')) {
|
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters -Raw:$Raw
|
||||||
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters -Raw:$Raw
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,17 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2021 v5.8.186
|
||||||
|
Created on: 2021-03-23 13:54
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Set-NetboxIPAMPrefix.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function Set-NetboxIPAMPrefix {
|
function Set-NetboxIPAMPrefix {
|
||||||
[CmdletBinding(ConfirmImpact = 'Medium',
|
[CmdletBinding(ConfirmImpact = 'Medium',
|
||||||
SupportsShouldProcess = $true)]
|
SupportsShouldProcess = $true)]
|
||||||
|
|
@ -6,40 +19,40 @@ function Set-NetboxIPAMPrefix {
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true,
|
[Parameter(Mandatory = $true,
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[uint64[]]$Id,
|
[uint16[]]$Id,
|
||||||
|
|
||||||
[string]$Prefix,
|
[string]$Prefix,
|
||||||
|
|
||||||
[string]$Status,
|
[string]$Status,
|
||||||
|
|
||||||
[uint64]$Tenant,
|
[uint16]$Tenant,
|
||||||
|
|
||||||
[uint64]$Site,
|
[uint16]$Site,
|
||||||
|
|
||||||
[uint64]$VRF,
|
[uint16]$VRF,
|
||||||
|
|
||||||
[uint64]$VLAN,
|
[uint16]$VLAN,
|
||||||
|
|
||||||
[object]$Role,
|
[object]$Role,
|
||||||
|
|
||||||
[hashtable]$Custom_Fields,
|
[hashtable]$Custom_Fields,
|
||||||
|
|
||||||
[string]$Description,
|
[string]$Description,
|
||||||
|
|
||||||
[switch]$Is_Pool,
|
[switch]$Is_Pool,
|
||||||
|
|
||||||
[switch]$Force
|
[switch]$Force
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
# Write-Verbose "Validating enum properties"
|
# Write-Verbose "Validating enum properties"
|
||||||
# $Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses', 0))
|
# $Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses', 0))
|
||||||
$Method = 'PATCH'
|
$Method = 'PATCH'
|
||||||
#
|
#
|
||||||
# # Value validation
|
# # Value validation
|
||||||
# $ModelDefinition = GetModelDefinitionFromURIPath -Segments $Segments -Method $Method
|
# $ModelDefinition = GetModelDefinitionFromURIPath -Segments $Segments -Method $Method
|
||||||
# $EnumProperties = GetModelEnumProperties -ModelDefinition $ModelDefinition
|
# $EnumProperties = GetModelEnumProperties -ModelDefinition $ModelDefinition
|
||||||
#
|
#
|
||||||
# foreach ($Property in $EnumProperties.Keys) {
|
# foreach ($Property in $EnumProperties.Keys) {
|
||||||
# if ($PSBoundParameters.ContainsKey($Property)) {
|
# if ($PSBoundParameters.ContainsKey($Property)) {
|
||||||
# Write-Verbose "Validating property [$Property] with value [$($PSBoundParameters.$Property)]"
|
# Write-Verbose "Validating property [$Property] with value [$($PSBoundParameters.$Property)]"
|
||||||
|
|
@ -48,22 +61,22 @@ function Set-NetboxIPAMPrefix {
|
||||||
# Write-Verbose "User did not provide a value for [$Property]"
|
# Write-Verbose "User did not provide a value for [$Property]"
|
||||||
# }
|
# }
|
||||||
# }
|
# }
|
||||||
#
|
#
|
||||||
# Write-Verbose "Finished enum validation"
|
# Write-Verbose "Finished enum validation"
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
foreach ($PrefixId in $Id) {
|
foreach ($PrefixId in $Id) {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes', $PrefixId))
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes', $PrefixId))
|
||||||
|
|
||||||
Write-Verbose "Obtaining Prefix from ID $PrefixId"
|
Write-Verbose "Obtaining Prefix from ID $PrefixId"
|
||||||
$CurrentPrefix = Get-NetboxIPAMPrefix -Id $PrefixId -ErrorAction Stop
|
$CurrentPrefix = Get-NetboxIPAMPrefix -Id $PrefixId -ErrorAction Stop
|
||||||
|
|
||||||
if ($Force -or $PSCmdlet.ShouldProcess($CurrentPrefix.Prefix, 'Set')) {
|
if ($Force -or $PSCmdlet.ShouldProcess($CurrentPrefix.Prefix, 'Set')) {
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method $Method
|
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method $Method
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,73 +0,0 @@
|
||||||
|
|
||||||
function Get-NetboxIPAMAddressRange {
|
|
||||||
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[Parameter(ParameterSetName = 'Query',
|
|
||||||
Position = 0)]
|
|
||||||
[string]$Range,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'ByID')]
|
|
||||||
[uint64[]]$Id,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[string]$Query,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[object]$Family,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[string]$VRF,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[uint32]$VRF_Id,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[string]$Tenant,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[uint32]$Tenant_Id,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[object]$Status,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[object]$Role,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[uint16]$Limit,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[uint16]$Offset,
|
|
||||||
|
|
||||||
[switch]$Raw
|
|
||||||
)
|
|
||||||
|
|
||||||
switch ($PSCmdlet.ParameterSetName) {
|
|
||||||
'ById' {
|
|
||||||
foreach ($Range_ID in $Id) {
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-ranges', $Range_ID))
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
|
||||||
}
|
|
||||||
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
default {
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-ranges'))
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
|
||||||
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,106 +0,0 @@
|
||||||
|
|
||||||
|
|
||||||
function New-NetboxIPAMAddressRange {
|
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Create a new IP address range to Netbox
|
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
Create a new IP address range to Netbox with a status of Active by default. The maximum supported
|
|
||||||
size of an IP range is 2^32 - 1.
|
|
||||||
|
|
||||||
.PARAMETER Start_Address
|
|
||||||
Starting IPv4 or IPv6 address (with mask). The maximum supported size of an IP range is 2^32 - 1.
|
|
||||||
|
|
||||||
.PARAMETER End_Address
|
|
||||||
Ending IPv4 or IPv6 address (with mask). The maximum supported size of an IP range is 2^32 - 1.
|
|
||||||
|
|
||||||
.PARAMETER Status
|
|
||||||
Operational status of this range. Defaults to Active
|
|
||||||
|
|
||||||
.PARAMETER Tenant
|
|
||||||
Tenant ID
|
|
||||||
|
|
||||||
.PARAMETER VRF
|
|
||||||
VRF ID
|
|
||||||
|
|
||||||
.PARAMETER Role
|
|
||||||
Role such as backup, customer, development, etc... Defaults to nothing
|
|
||||||
|
|
||||||
.PARAMETER Custom_Fields
|
|
||||||
Custom field hash table. Will be validated by the API service
|
|
||||||
|
|
||||||
.PARAMETER Description
|
|
||||||
Description of IP address range
|
|
||||||
|
|
||||||
.PARAMETER Comments
|
|
||||||
Extra comments (markdown supported).
|
|
||||||
|
|
||||||
.PARAMETER Tags
|
|
||||||
One or more tags.
|
|
||||||
|
|
||||||
.PARAMETER Mark_Utilized
|
|
||||||
Treat as 100% utilized
|
|
||||||
|
|
||||||
.PARAMETER Raw
|
|
||||||
Return raw results from API service
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
New-NetboxIPAMAddressRange -Start_Address 192.0.2.20/24 -End_Address 192.0.2.20/24
|
|
||||||
|
|
||||||
Add new IP Address range from 192.0.2.20/24 to 192.0.2.20/24 with status active
|
|
||||||
|
|
||||||
.NOTES
|
|
||||||
https://netbox.neonet.org/static/docs/models/ipam/iprange/
|
|
||||||
#>
|
|
||||||
|
|
||||||
[CmdletBinding(ConfirmImpact = 'Low',
|
|
||||||
SupportsShouldProcess = $true)]
|
|
||||||
[OutputType([pscustomobject])]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[string]$Start_Address,
|
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[string]$End_Address,
|
|
||||||
|
|
||||||
[object]$Status = 'Active',
|
|
||||||
|
|
||||||
[uint64]$Tenant,
|
|
||||||
|
|
||||||
[uint64]$VRF,
|
|
||||||
|
|
||||||
[object]$Role,
|
|
||||||
|
|
||||||
[hashtable]$Custom_Fields,
|
|
||||||
|
|
||||||
[string]$Description,
|
|
||||||
|
|
||||||
[string]$Comments,
|
|
||||||
|
|
||||||
[object[]]$Tags,
|
|
||||||
|
|
||||||
[switch]$Mark_Utilized,
|
|
||||||
|
|
||||||
[switch]$Raw
|
|
||||||
)
|
|
||||||
|
|
||||||
process {
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-ranges'))
|
|
||||||
$Method = 'POST'
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
|
||||||
|
|
||||||
if ($PSCmdlet.ShouldProcess($Start_Address, 'Create new IP address range')) {
|
|
||||||
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
|
|
||||||
function Remove-NetboxIPAMAddressRange {
|
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Remove an IP address range from Netbox
|
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
Removes/deletes an IP address range from Netbox by ID
|
|
||||||
|
|
||||||
.PARAMETER Id
|
|
||||||
Database ID of the IP address range object.
|
|
||||||
|
|
||||||
.PARAMETER Force
|
|
||||||
Do not confirm.
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
PS C:\> Remove-NetboxIPAMAddressRange -Id 1234
|
|
||||||
|
|
||||||
.NOTES
|
|
||||||
Additional information about the function.
|
|
||||||
#>
|
|
||||||
|
|
||||||
[CmdletBinding(ConfirmImpact = 'High',
|
|
||||||
SupportsShouldProcess = $true)]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[Parameter(Mandatory = $true,
|
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
|
||||||
[uint64[]]$Id,
|
|
||||||
|
|
||||||
[switch]$Force
|
|
||||||
)
|
|
||||||
|
|
||||||
process {
|
|
||||||
foreach ($Range_Id in $Id) {
|
|
||||||
$CurrentRange = Get-NetboxIPAMAddressRange -Id $Range_Id -ErrorAction Stop
|
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-ranges', $Range_Id))
|
|
||||||
|
|
||||||
if ($Force -or $pscmdlet.ShouldProcess($CurrentRange.start_address, "Delete")) {
|
|
||||||
$URI = BuildNewURI -Segments $Segments
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Method DELETE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
|
|
||||||
function Set-NetboxIPAMAddressRange {
|
|
||||||
[CmdletBinding(ConfirmImpact = 'Medium',
|
|
||||||
SupportsShouldProcess = $true)]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[Parameter(Mandatory = $true,
|
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
|
||||||
[uint64[]]$Id,
|
|
||||||
|
|
||||||
[string]$Start_Address,
|
|
||||||
|
|
||||||
[string]$End_Address,
|
|
||||||
|
|
||||||
[object]$Status,
|
|
||||||
|
|
||||||
[uint64]$Tenant,
|
|
||||||
|
|
||||||
[uint64]$VRF,
|
|
||||||
|
|
||||||
[object]$Role,
|
|
||||||
|
|
||||||
[hashtable]$Custom_Fields,
|
|
||||||
|
|
||||||
[string]$Description,
|
|
||||||
|
|
||||||
[string]$Comments,
|
|
||||||
|
|
||||||
[object[]]$Tags,
|
|
||||||
|
|
||||||
[switch]$Mark_Utilized,
|
|
||||||
|
|
||||||
[switch]$Force,
|
|
||||||
|
|
||||||
[switch]$Raw
|
|
||||||
)
|
|
||||||
|
|
||||||
begin {
|
|
||||||
$Method = 'PATCH'
|
|
||||||
}
|
|
||||||
|
|
||||||
process {
|
|
||||||
foreach ($RangeID in $Id) {
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-ranges', $RangeID))
|
|
||||||
|
|
||||||
Write-Verbose "Obtaining IP range from ID $RangeID"
|
|
||||||
$CurrentRange = Get-NetboxIPAMAddressRange -Id $RangeID -ErrorAction Stop
|
|
||||||
|
|
||||||
if ($Force -or $PSCmdlet.ShouldProcess("$($CurrentRange.Start_Address) - $($CurrentRange.End_Address)", 'Set')) {
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
|
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method $Method
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -3,93 +3,93 @@ function Get-NetboxIPAMRole {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Get IPAM Prefix/VLAN roles
|
Get IPAM Prefix/VLAN roles
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
A role indicates the function of a prefix or VLAN. For example, you might define Data, Voice, and Security roles. Generally, a prefix will be assigned the same functional role as the VLAN to which it is assigned (if any).
|
A role indicates the function of a prefix or VLAN. For example, you might define Data, Voice, and Security roles. Generally, a prefix will be assigned the same functional role as the VLAN to which it is assigned (if any).
|
||||||
|
|
||||||
.PARAMETER Id
|
.PARAMETER Id
|
||||||
Unique ID
|
Unique ID
|
||||||
|
|
||||||
.PARAMETER Query
|
.PARAMETER Query
|
||||||
Search query
|
Search query
|
||||||
|
|
||||||
.PARAMETER Name
|
.PARAMETER Name
|
||||||
Role name
|
Role name
|
||||||
|
|
||||||
.PARAMETER Slug
|
.PARAMETER Slug
|
||||||
Role URL slug
|
Role URL slug
|
||||||
|
|
||||||
.PARAMETER Brief
|
.PARAMETER Brief
|
||||||
Brief format
|
Brief format
|
||||||
|
|
||||||
.PARAMETER Limit
|
.PARAMETER Limit
|
||||||
Result limit
|
Result limit
|
||||||
|
|
||||||
.PARAMETER Offset
|
.PARAMETER Offset
|
||||||
Result offset
|
Result offset
|
||||||
|
|
||||||
.PARAMETER Raw
|
.PARAMETER Raw
|
||||||
A description of the Raw parameter.
|
A description of the Raw parameter.
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> Get-NetboxIPAMRole
|
PS C:\> Get-NetboxIPAMRole
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Additional information about the function.
|
Additional information about the function.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(ParameterSetName = 'Query',
|
[Parameter(ParameterSetName = 'Query',
|
||||||
Position = 0)]
|
Position = 0)]
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Query,
|
[string]$Query,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'ByID')]
|
[Parameter(ParameterSetName = 'ByID')]
|
||||||
[uint64[]]$Id,
|
[uint32[]]$Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Slug,
|
[string]$Slug,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[switch]$Brief,
|
[switch]$Brief,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint16]$Limit,
|
[uint16]$Limit,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint16]$Offset,
|
[uint16]$Offset,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
switch ($PSCmdlet.ParameterSetName) {
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
'ById' {
|
'ById' {
|
||||||
foreach ($Role_ID in $Id) {
|
foreach ($Role_ID in $Id) {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'roles', $Role_ID))
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'roles', $Role_ID))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
}
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
default {
|
default {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'roles'))
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'roles'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,91 +1,108 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/16/2020 16:34
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Get-NetboxIPAMVLAN.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxIPAMVLAN {
|
function Get-NetboxIPAMVLAN {
|
||||||
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
[CmdletBinding()]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(ParameterSetName = 'Query',
|
[Parameter(ParameterSetName = 'Query',
|
||||||
Position = 0)]
|
Position = 0)]
|
||||||
[ValidateRange(1, 4096)]
|
[ValidateRange(1, 4096)]
|
||||||
[uint16]$VID,
|
[uint16]$VID,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'ByID')]
|
[Parameter(ParameterSetName = 'ByID')]
|
||||||
[uint64[]]$Id,
|
[uint32[]]$Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Query,
|
[string]$Query,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Tenant,
|
[string]$Tenant,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint64]$Tenant_Id,
|
[uint32]$Tenant_Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$TenantGroup,
|
[string]$TenantGroup,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint64]$TenantGroup_Id,
|
[uint32]$TenantGroup_Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[object]$Status,
|
[object]$Status,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Region,
|
[string]$Region,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Site,
|
[string]$Site,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint64]$Site_Id,
|
[uint32]$Site_Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Group,
|
[string]$Group,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint64]$Group_Id,
|
[uint32]$Group_Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Role,
|
[string]$Role,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint64]$Role_Id,
|
[uint32]$Role_Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint16]$Limit,
|
[uint16]$Limit,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint16]$Offset,
|
[uint16]$Offset,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# if ($null -ne $Status) {
|
||||||
|
# $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -VLANStatus
|
||||||
|
# }
|
||||||
|
|
||||||
switch ($PSCmdlet.ParameterSetName) {
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
'ById' {
|
'ById' {
|
||||||
foreach ($VLAN_ID in $Id) {
|
foreach ($VLAN_ID in $Id) {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'vlans', $VLAN_ID))
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'vlans', $VLAN_ID))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
}
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
default {
|
default {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'vlans'))
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'vlans'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,82 +1,79 @@
|
||||||
function New-NetboxIPAMVLAN {
|
function New-NetboxIPAMVLAN {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Create a new VLAN
|
Create a new VLAN
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Create a new VLAN in Netbox with a status of Active by default.
|
Create a new VLAN in Netbox with a status of Active by default.
|
||||||
|
|
||||||
.PARAMETER VID
|
.PARAMETER VID
|
||||||
The VLAN ID.
|
The VLAN ID.
|
||||||
|
|
||||||
.PARAMETER Name
|
.PARAMETER Name
|
||||||
The name of the VLAN.
|
The name of the VLAN.
|
||||||
|
|
||||||
.PARAMETER Status
|
.PARAMETER Status
|
||||||
Status of the VLAN. Defaults to Active
|
Status of the VLAN. Defaults to Active
|
||||||
|
|
||||||
.PARAMETER Tenant
|
.PARAMETER Tenant
|
||||||
Tenant ID
|
Tenant ID
|
||||||
|
|
||||||
.PARAMETER Role
|
.PARAMETER Role
|
||||||
Role such as anycast, loopback, etc... Defaults to nothing
|
Role such as anycast, loopback, etc... Defaults to nothing
|
||||||
|
|
||||||
.PARAMETER Description
|
.PARAMETER Description
|
||||||
Description of IP address
|
Description of IP address
|
||||||
|
|
||||||
.PARAMETER Custom_Fields
|
.PARAMETER Custom_Fields
|
||||||
Custom field hash table. Will be validated by the API service
|
Custom field hash table. Will be validated by the API service
|
||||||
|
|
||||||
.PARAMETER Raw
|
.PARAMETER Raw
|
||||||
Return raw results from API service
|
Return raw results from API service
|
||||||
|
|
||||||
.PARAMETER Address
|
.PARAMETER Address
|
||||||
IP address in CIDR notation: 192.168.1.1/24
|
IP address in CIDR notation: 192.168.1.1/24
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> Create-NetboxIPAMAddress
|
PS C:\> Create-NetboxIPAMAddress
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Additional information about the function.
|
Additional information about the function.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding(ConfirmImpact = 'low',
|
[CmdletBinding()]
|
||||||
SupportsShouldProcess = $true)]
|
|
||||||
[OutputType([pscustomobject])]
|
[OutputType([pscustomobject])]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[uint16]$VID,
|
[uint16]$VID,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[object]$Status = 'Active',
|
[object]$Status = 'Active',
|
||||||
|
|
||||||
[uint64]$Tenant,
|
[uint16]$Tenant,
|
||||||
|
|
||||||
[object]$Role,
|
[object]$Role,
|
||||||
|
|
||||||
[string]$Description,
|
[string]$Description,
|
||||||
|
|
||||||
[hashtable]$Custom_Fields,
|
[hashtable]$Custom_Fields,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
# $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -VLANStatus
|
# $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -VLANStatus
|
||||||
|
#
|
||||||
# if ($null -ne $Role) {
|
# if ($null -ne $Role) {
|
||||||
# $PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -IPAddressRole
|
# $PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -IPAddressRole
|
||||||
# }
|
# }
|
||||||
|
|
||||||
$segments = [System.Collections.ArrayList]::new(@('ipam', 'vlans'))
|
$segments = [System.Collections.ArrayList]::new(@('ipam', 'vlans'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $segments -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
if ($PSCmdlet.ShouldProcess($nae, 'Create new Vlan $($vid)')) {
|
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters -Raw:$Raw
|
||||||
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters -Raw:$Raw
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
function Clear-NetboxCredential {
|
|
||||||
[CmdletBinding(ConfirmImpact = 'Medium', SupportsShouldProcess = $true)]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[switch]$Force
|
|
||||||
)
|
|
||||||
|
|
||||||
if ($Force -or ($PSCmdlet.ShouldProcess('Netbox Credentials', 'Clear'))) {
|
|
||||||
$script:NetboxConfig.Credential = $null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -85,8 +85,6 @@
|
||||||
|
|
||||||
#for PowerShell (<=) 5 (Desktop), Enable TLS 1.1, 1.2 and Disable SSL chain trust
|
#for PowerShell (<=) 5 (Desktop), Enable TLS 1.1, 1.2 and Disable SSL chain trust
|
||||||
if ("Desktop" -eq $PSVersionTable.PsEdition) {
|
if ("Desktop" -eq $PSVersionTable.PsEdition) {
|
||||||
#Add System.web (Need for ParseQueryString)
|
|
||||||
Add-Type -AssemblyName System.Web
|
|
||||||
#Enable TLS 1.1 and 1.2
|
#Enable TLS 1.1 and 1.2
|
||||||
Set-NetboxCipherSSL
|
Set-NetboxCipherSSL
|
||||||
if ($SkipCertificateCheck) {
|
if ($SkipCertificateCheck) {
|
||||||
|
|
@ -148,7 +146,14 @@
|
||||||
$script:NetboxConfig.Connected = $true
|
$script:NetboxConfig.Connected = $true
|
||||||
Write-Verbose "Successfully connected!"
|
Write-Verbose "Successfully connected!"
|
||||||
|
|
||||||
$script:NetboxConfig.ContentTypes = Get-NetboxContentType -Limit 500
|
#Write-Verbose "Caching static choices"
|
||||||
|
#$script:NetboxConfig.Choices.Circuits = Get-NetboxCircuitsChoices
|
||||||
|
#$script:NetboxConfig.Choices.DCIM = Get-NetboxDCIMChoices # Not completed yet
|
||||||
|
#$script:NetboxConfig.Choices.Extras = Get-NetboxExtrasChoices
|
||||||
|
#$script:NetboxConfig.Choices.IPAM = Get-NetboxIPAMChoices
|
||||||
|
##$script:NetboxConfig.Choices.Secrets = Get-NetboxSecretsChoices # Not completed yet
|
||||||
|
##$script:NetboxConfig.Choices.Tenancy = Get-NetboxTenancyChoices
|
||||||
|
#$script:NetboxConfig.Choices.Virtualization = Get-NetboxVirtualizationChoices
|
||||||
|
|
||||||
Write-Verbose "Connection process completed"
|
Write-Verbose "Connection process completed"
|
||||||
}
|
}
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
function Get-NetboxHostPort {
|
function Get-NetboxHostPort {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param ()
|
param ()
|
||||||
|
|
||||||
Write-Verbose "Getting Netbox host port"
|
Write-Verbose "Getting Netbox host port"
|
||||||
if ($null -eq $script:NetboxConfig.HostPort) {
|
if ($null -eq $script:NetboxConfig.HostPort) {
|
||||||
throw "Netbox host port is not set! You may set it with Set-NetboxHostPort -Port 'https'"
|
throw "Netbox host port is not set! You may set it with Set-NetboxHostPort -Port 'https'"
|
||||||
}
|
}
|
||||||
|
|
||||||
$script:NetboxConfig.HostPort
|
$script:NetboxConfig.HostPort
|
||||||
}
|
}
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
function Get-NetboxHostScheme {
|
function Get-NetboxHostScheme {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param ()
|
param ()
|
||||||
|
|
||||||
Write-Verbose "Getting Netbox host scheme"
|
Write-Verbose "Getting Netbox host scheme"
|
||||||
if ($null -eq $script:NetboxConfig.Hostscheme) {
|
if ($null -eq $script:NetboxConfig.Hostscheme) {
|
||||||
throw "Netbox host sceme is not set! You may set it with Set-NetboxHostScheme -Scheme 'https'"
|
throw "Netbox host sceme is not set! You may set it with Set-NetboxHostScheme -Scheme 'https'"
|
||||||
}
|
}
|
||||||
|
|
||||||
$script:NetboxConfig.HostScheme
|
$script:NetboxConfig.HostScheme
|
||||||
}
|
}
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[uint16]$Port
|
[uint16]$Port
|
||||||
)
|
)
|
||||||
|
|
||||||
if ($PSCmdlet.ShouldProcess('Netbox Port', 'Set')) {
|
if ($PSCmdlet.ShouldProcess('Netbox Port', 'Set')) {
|
||||||
$script:NetboxConfig.HostPort = $Port
|
$script:NetboxConfig.HostPort = $Port
|
||||||
$script:NetboxConfig.HostPort
|
$script:NetboxConfig.HostPort
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,12 @@
|
||||||
[ValidateSet('https', 'http', IgnoreCase = $true)]
|
[ValidateSet('https', 'http', IgnoreCase = $true)]
|
||||||
[string]$Scheme = 'https'
|
[string]$Scheme = 'https'
|
||||||
)
|
)
|
||||||
|
|
||||||
if ($PSCmdlet.ShouldProcess('Netbox Host Scheme', 'Set')) {
|
if ($PSCmdlet.ShouldProcess('Netbox Host Scheme', 'Set')) {
|
||||||
if ($Scheme -eq 'http') {
|
if ($Scheme -eq 'http') {
|
||||||
Write-Warning "Connecting via non-secure HTTP is not-recommended"
|
Write-Warning "Connecting via non-secure HTTP is not-recommended"
|
||||||
}
|
}
|
||||||
|
|
||||||
$script:NetboxConfig.HostScheme = $Scheme
|
$script:NetboxConfig.HostScheme = $Scheme
|
||||||
$script:NetboxConfig.HostScheme
|
$script:NetboxConfig.HostScheme
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,27 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.174
|
||||||
|
Created on: 4/28/2020 11:57
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Get-NetboxAPIDefinition.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxAPIDefinition {
|
function Get-NetboxAPIDefinition {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param ()
|
||||||
(
|
|
||||||
[ValidateSet('json', 'yaml', IgnoreCase = $true)]
|
|
||||||
[string]$Format = 'json'
|
|
||||||
)
|
|
||||||
|
|
||||||
#$URI = "https://netbox.neonet.org/api/schema/?format=json"
|
#$URI = "https://netbox.neonet.org/api/docs/?format=openapi"
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('schema'))
|
$Segments = [System.Collections.ArrayList]::new(@('docs'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary @{
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary @{'format' = 'openapi' }
|
||||||
'format' = $Format.ToLower()
|
|
||||||
}
|
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters -SkipConnectedCheck
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters -SkipConnectedCheck
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,89 +0,0 @@
|
||||||
function Get-NetboxContentType {
|
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Get a content type definition from Netbox
|
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
A detailed description of the Get-NetboxContentType function.
|
|
||||||
|
|
||||||
.PARAMETER Model
|
|
||||||
A description of the Model parameter.
|
|
||||||
|
|
||||||
.PARAMETER Id
|
|
||||||
The database ID of the contact role
|
|
||||||
|
|
||||||
.PARAMETER App_Label
|
|
||||||
A description of the App_Label parameter.
|
|
||||||
|
|
||||||
.PARAMETER Query
|
|
||||||
A standard search query that will match one or more contact roles.
|
|
||||||
|
|
||||||
.PARAMETER Limit
|
|
||||||
Limit the number of results to this number
|
|
||||||
|
|
||||||
.PARAMETER Offset
|
|
||||||
Start the search at this index in results
|
|
||||||
|
|
||||||
.PARAMETER Raw
|
|
||||||
Return the unparsed data from the HTTP request
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
PS C:\> Get-NetboxContentType
|
|
||||||
|
|
||||||
.NOTES
|
|
||||||
Additional information about the function.
|
|
||||||
#>
|
|
||||||
|
|
||||||
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[Parameter(ParameterSetName = 'Query',
|
|
||||||
Position = 0)]
|
|
||||||
[string]$Model,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'ByID')]
|
|
||||||
[uint64[]]$Id,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[string]$App_Label,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[string]$Query,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[uint16]$Limit,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[uint16]$Offset,
|
|
||||||
|
|
||||||
[switch]$Raw
|
|
||||||
)
|
|
||||||
|
|
||||||
switch ($PSCmdlet.ParameterSetName) {
|
|
||||||
'ById' {
|
|
||||||
foreach ($ContentType_ID in $Id) {
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('extras', 'content-types', $ContentType_ID))
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
|
||||||
}
|
|
||||||
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
default {
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('extras', 'content-types'))
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
|
||||||
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -13,7 +13,6 @@
|
||||||
'Choices' = @{
|
'Choices' = @{
|
||||||
}
|
}
|
||||||
'APIDefinition' = $null
|
'APIDefinition' = $null
|
||||||
'ContentTypes' = $null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
|
|
||||||
function Test-NetboxAPIConnected {
|
|
||||||
[CmdletBinding()]
|
|
||||||
param ()
|
|
||||||
|
|
||||||
$script:NetboxConfig.Connected
|
|
||||||
}
|
|
||||||
|
|
@ -1,108 +0,0 @@
|
||||||
|
|
||||||
function Get-NetboxContactAssignment {
|
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Get a contact Assignment from Netbox
|
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
A detailed description of the Get-NetboxContactAssignment function.
|
|
||||||
|
|
||||||
.PARAMETER Name
|
|
||||||
The specific name of the contact Assignment. Must match exactly as is defined in Netbox
|
|
||||||
|
|
||||||
.PARAMETER Id
|
|
||||||
The database ID of the contact Assignment
|
|
||||||
|
|
||||||
.PARAMETER Content_Type_Id
|
|
||||||
A description of the Content_Type_Id parameter.
|
|
||||||
|
|
||||||
.PARAMETER Content_Type
|
|
||||||
A description of the Content_Type parameter.
|
|
||||||
|
|
||||||
.PARAMETER Object_Id
|
|
||||||
A description of the Object_Id parameter.
|
|
||||||
|
|
||||||
.PARAMETER Contact_Id
|
|
||||||
A description of the Contact_Id parameter.
|
|
||||||
|
|
||||||
.PARAMETER Role_Id
|
|
||||||
A description of the Role_Id parameter.
|
|
||||||
|
|
||||||
.PARAMETER Limit
|
|
||||||
Limit the number of results to this number
|
|
||||||
|
|
||||||
.PARAMETER Offset
|
|
||||||
Start the search at this index in results
|
|
||||||
|
|
||||||
.PARAMETER Raw
|
|
||||||
Return the unparsed data from the HTTP request
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
PS C:\> Get-NetboxContactAssignment
|
|
||||||
|
|
||||||
.NOTES
|
|
||||||
Additional information about the function.
|
|
||||||
#>
|
|
||||||
|
|
||||||
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[Parameter(ParameterSetName = 'Query',
|
|
||||||
Position = 0)]
|
|
||||||
[string]$Name,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'ByID')]
|
|
||||||
[uint64[]]$Id,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[uint64]$Content_Type_Id,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[string]$Content_Type,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[uint64]$Object_Id,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[uint64]$Contact_Id,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[uint64]$Role_Id,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[uint16]$Limit,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[uint16]$Offset,
|
|
||||||
|
|
||||||
[switch]$Raw
|
|
||||||
)
|
|
||||||
|
|
||||||
switch ($PSCmdlet.ParameterSetName) {
|
|
||||||
'ById' {
|
|
||||||
foreach ($ContactAssignment_ID in $Id) {
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contact-assignments', $ContactAssignment_ID))
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
|
||||||
}
|
|
||||||
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
default {
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contact-assignments'))
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
|
||||||
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,79 +0,0 @@
|
||||||
|
|
||||||
function New-NetboxContactAssignment {
|
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Create a new contact role assignment in Netbox
|
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
Creates a new contact role assignment in Netbox
|
|
||||||
|
|
||||||
.PARAMETER Content_Type
|
|
||||||
The content type for this assignment.
|
|
||||||
|
|
||||||
.PARAMETER Object_Id
|
|
||||||
ID of the object to assign.
|
|
||||||
|
|
||||||
.PARAMETER Contact
|
|
||||||
ID of the contact to assign.
|
|
||||||
|
|
||||||
.PARAMETER Role
|
|
||||||
ID of the contact role to assign.
|
|
||||||
|
|
||||||
.PARAMETER Priority
|
|
||||||
Piority of the contact assignment.
|
|
||||||
|
|
||||||
.PARAMETER Raw
|
|
||||||
Return the unparsed data from the HTTP request
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
PS C:\> New-NetboxContactAssignment -Content_Type 'dcim.location' -Object_id 10 -Contact 15 -Role 10 -Priority 'Primary'
|
|
||||||
|
|
||||||
.NOTES
|
|
||||||
Valid content types: https://docs.netbox.dev/en/stable/features/contacts/#contacts_1
|
|
||||||
#>
|
|
||||||
|
|
||||||
[CmdletBinding(ConfirmImpact = 'Low',
|
|
||||||
SupportsShouldProcess = $true)]
|
|
||||||
[OutputType([pscustomobject])]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[Parameter(Mandatory = $true,
|
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
|
||||||
[ValidateSet('circuits.circuit', 'circuits.provider', 'circuits.provideraccount', 'dcim.device', 'dcim.location', 'dcim.manufacturer', 'dcim.powerpanel', 'dcim.rack', 'dcim.region', 'dcim.site', 'dcim.sitegroup', 'tenancy.tenant', 'virtualization.cluster', 'virtualization.clustergroup', 'virtualization.virtualmachine', IgnoreCase = $true)]
|
|
||||||
[string]$Content_Type,
|
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[uint64]$Object_Id,
|
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[uint64]$Contact,
|
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[uint64]$Role,
|
|
||||||
|
|
||||||
[ValidateSet('primary', 'secondary', 'tertiary', 'inactive', IgnoreCase = $true)]
|
|
||||||
[string]$Priority,
|
|
||||||
|
|
||||||
[switch]$Raw
|
|
||||||
)
|
|
||||||
|
|
||||||
begin {
|
|
||||||
$Method = 'POST'
|
|
||||||
}
|
|
||||||
|
|
||||||
process {
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contact-assignments'))
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
|
||||||
|
|
||||||
if ($PSCmdlet.ShouldProcess($Content_Type, 'Create new contact assignment')) {
|
|
||||||
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,84 +0,0 @@
|
||||||
|
|
||||||
|
|
||||||
function Set-NetboxContactAssignment {
|
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Update a contact role assignment in Netbox
|
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
Updates a contact role assignment in Netbox
|
|
||||||
|
|
||||||
.PARAMETER Content_Type
|
|
||||||
The content type for this assignment.
|
|
||||||
|
|
||||||
.PARAMETER Object_Id
|
|
||||||
ID of the object to assign.
|
|
||||||
|
|
||||||
.PARAMETER Contact
|
|
||||||
ID of the contact to assign.
|
|
||||||
|
|
||||||
.PARAMETER Role
|
|
||||||
ID of the contact role to assign.
|
|
||||||
|
|
||||||
.PARAMETER Priority
|
|
||||||
Priority of the contact assignment.
|
|
||||||
|
|
||||||
.PARAMETER Raw
|
|
||||||
Return the unparsed data from the HTTP request
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
PS C:\> Set-NetboxContactAssignment -Id 11 -Content_Type 'dcim.location' -Object_id 10 -Contact 15 -Role 10 -Priority 'Primary'
|
|
||||||
|
|
||||||
.NOTES
|
|
||||||
Valid content types: https://docs.netbox.dev/en/stable/features/contacts/#contacts_1
|
|
||||||
#>
|
|
||||||
|
|
||||||
[CmdletBinding(ConfirmImpact = 'Low',
|
|
||||||
SupportsShouldProcess = $true)]
|
|
||||||
[OutputType([pscustomobject])]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[Parameter(Mandatory = $true,
|
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
|
||||||
[uint64[]]$Id,
|
|
||||||
|
|
||||||
[Parameter(ValueFromPipelineByPropertyName = $true)]
|
|
||||||
[ValidateSet('circuits.circuit', 'circuits.provider', 'circuits.provideraccount', 'dcim.device', 'dcim.location', 'dcim.manufacturer', 'dcim.powerpanel', 'dcim.rack', 'dcim.region', 'dcim.site', 'dcim.sitegroup', 'tenancy.tenant', 'virtualization.cluster', 'virtualization.clustergroup', 'virtualization.virtualmachine', IgnoreCase = $true)]
|
|
||||||
[string]$Content_Type,
|
|
||||||
|
|
||||||
[uint64]$Object_Id,
|
|
||||||
|
|
||||||
[uint64]$Contact,
|
|
||||||
|
|
||||||
[uint64]$Role,
|
|
||||||
|
|
||||||
[ValidateSet('primary', 'secondary', 'tertiary', 'inactive', IgnoreCase = $true)]
|
|
||||||
[string]$Priority,
|
|
||||||
|
|
||||||
[switch]$Raw
|
|
||||||
)
|
|
||||||
|
|
||||||
begin {
|
|
||||||
$Method = 'Patch'
|
|
||||||
}
|
|
||||||
|
|
||||||
process {
|
|
||||||
foreach ($ContactAssignmentId in $Id) {
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contact-assignments', $ContactAssignmentId))
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
|
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
|
||||||
|
|
||||||
$CurrentContactAssignment = Get-NetboxContactAssignment -Id $ContactAssignmentId -ErrorAction Stop
|
|
||||||
|
|
||||||
if ($PSCmdlet.ShouldProcess($CurrentContactAssignment.Id, 'Update contact assignment')) {
|
|
||||||
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,90 +0,0 @@
|
||||||
|
|
||||||
function Get-NetboxContactRole {
|
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Get a contact role from Netbox
|
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
A detailed description of the Get-NetboxContactRole function.
|
|
||||||
|
|
||||||
.PARAMETER Name
|
|
||||||
The specific name of the contact role. Must match exactly as is defined in Netbox
|
|
||||||
|
|
||||||
.PARAMETER Id
|
|
||||||
The database ID of the contact role
|
|
||||||
|
|
||||||
.PARAMETER Query
|
|
||||||
A standard search query that will match one or more contact roles.
|
|
||||||
|
|
||||||
.PARAMETER Limit
|
|
||||||
Limit the number of results to this number
|
|
||||||
|
|
||||||
.PARAMETER Offset
|
|
||||||
Start the search at this index in results
|
|
||||||
|
|
||||||
.PARAMETER Raw
|
|
||||||
Return the unparsed data from the HTTP request
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
PS C:\> Get-NetboxContactRole
|
|
||||||
|
|
||||||
.NOTES
|
|
||||||
Additional information about the function.
|
|
||||||
#>
|
|
||||||
|
|
||||||
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[Parameter(ParameterSetName = 'Query',
|
|
||||||
Position = 0)]
|
|
||||||
[string]$Name,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'ByID')]
|
|
||||||
[uint64[]]$Id,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[string]$Query,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[string]$Slug,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[string]$Description,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[uint16]$Limit,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[uint16]$Offset,
|
|
||||||
|
|
||||||
[switch]$Raw
|
|
||||||
)
|
|
||||||
|
|
||||||
switch ($PSCmdlet.ParameterSetName) {
|
|
||||||
'ById' {
|
|
||||||
foreach ($ContactRole_ID in $Id) {
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contact-roles', $ContactRole_ID))
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
|
||||||
}
|
|
||||||
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
default {
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contact-roles'))
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
|
||||||
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,71 +0,0 @@
|
||||||
|
|
||||||
function New-NetboxContactRole {
|
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Create a new contact role in Netbox
|
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
Creates a new contact role object in Netbox
|
|
||||||
|
|
||||||
.PARAMETER Name
|
|
||||||
The contact role name, e.g "Network Support"
|
|
||||||
|
|
||||||
.PARAMETER Slug
|
|
||||||
The unique URL for the role. Can only contain hypens, A-Z, a-z, 0-9, and underscores
|
|
||||||
|
|
||||||
.PARAMETER Description
|
|
||||||
Short description of the contact role
|
|
||||||
|
|
||||||
.PARAMETER Custom_Fields
|
|
||||||
A description of the Custom_Fields parameter.
|
|
||||||
|
|
||||||
.PARAMETER Raw
|
|
||||||
Return the unparsed data from the HTTP request
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
PS C:\> New-NetboxContact -Name 'Leroy Jenkins' -Email 'leroy.jenkins@example.com'
|
|
||||||
|
|
||||||
.NOTES
|
|
||||||
Additional information about the function.
|
|
||||||
#>
|
|
||||||
|
|
||||||
[CmdletBinding(ConfirmImpact = 'Low',
|
|
||||||
SupportsShouldProcess = $true)]
|
|
||||||
[OutputType([pscustomobject])]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[Parameter(Mandatory = $true,
|
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
|
||||||
[ValidateLength(1, 100)]
|
|
||||||
[string]$Name,
|
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[ValidateLength(1, 100)]
|
|
||||||
[ValidatePattern('^[-a-zA-Z0-9_]+$')]
|
|
||||||
[string]$Slug,
|
|
||||||
|
|
||||||
[ValidateLength(0, 200)]
|
|
||||||
[string]$Description,
|
|
||||||
|
|
||||||
[hashtable]$Custom_Fields,
|
|
||||||
|
|
||||||
[switch]$Raw
|
|
||||||
)
|
|
||||||
|
|
||||||
process {
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contacts'))
|
|
||||||
$Method = 'POST'
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
|
||||||
|
|
||||||
if ($PSCmdlet.ShouldProcess($Name, 'Create new contact')) {
|
|
||||||
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,80 +0,0 @@
|
||||||
|
|
||||||
function Set-NetboxContactRole {
|
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Update a contact role in Netbox
|
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
Updates a contact role in Netbox
|
|
||||||
|
|
||||||
.PARAMETER Name
|
|
||||||
The contact role name, e.g "Network Support"
|
|
||||||
|
|
||||||
.PARAMETER Slug
|
|
||||||
The unique URL for the role. Can only contain hypens, A-Z, a-z, 0-9, and underscores
|
|
||||||
|
|
||||||
.PARAMETER Description
|
|
||||||
Short description of the contact role
|
|
||||||
|
|
||||||
.PARAMETER Custom_Fields
|
|
||||||
A description of the Custom_Fields parameter.
|
|
||||||
|
|
||||||
.PARAMETER Raw
|
|
||||||
Return the unparsed data from the HTTP request
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
PS C:\> New-NetboxContact -Name 'Leroy Jenkins' -Email 'leroy.jenkins@example.com'
|
|
||||||
|
|
||||||
.NOTES
|
|
||||||
Additional information about the function.
|
|
||||||
#>
|
|
||||||
|
|
||||||
[CmdletBinding(ConfirmImpact = 'Low',
|
|
||||||
SupportsShouldProcess = $true)]
|
|
||||||
[OutputType([pscustomobject])]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,120 +0,0 @@
|
||||||
|
|
||||||
function Get-NetboxContact {
|
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Get a contact from Netbox
|
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
Obtain a contact or contacts from Netbox by ID or query
|
|
||||||
|
|
||||||
.PARAMETER Name
|
|
||||||
The specific name of the Contact. Must match exactly as is defined in Netbox
|
|
||||||
|
|
||||||
.PARAMETER Id
|
|
||||||
The database ID of the Contact
|
|
||||||
|
|
||||||
.PARAMETER Query
|
|
||||||
A standard search query that will match one or more Contacts.
|
|
||||||
|
|
||||||
.PARAMETER Email
|
|
||||||
Email address of the contact
|
|
||||||
|
|
||||||
.PARAMETER Title
|
|
||||||
Title of the contact
|
|
||||||
|
|
||||||
.PARAMETER Phone
|
|
||||||
Telephone number of the contact
|
|
||||||
|
|
||||||
.PARAMETER Address
|
|
||||||
Physical address of the contact
|
|
||||||
|
|
||||||
.PARAMETER Group
|
|
||||||
The specific group as defined in Netbox.
|
|
||||||
|
|
||||||
.PARAMETER GroupID
|
|
||||||
The database ID of the group in Netbox
|
|
||||||
|
|
||||||
.PARAMETER Limit
|
|
||||||
Limit the number of results to this number
|
|
||||||
|
|
||||||
.PARAMETER Offset
|
|
||||||
Start the search at this index in results
|
|
||||||
|
|
||||||
.PARAMETER Raw
|
|
||||||
Return the unparsed data from the HTTP request
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
PS C:\> Get-NetboxContact
|
|
||||||
|
|
||||||
.NOTES
|
|
||||||
Additional information about the function.
|
|
||||||
#>
|
|
||||||
|
|
||||||
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[Parameter(ParameterSetName = 'Query',
|
|
||||||
Position = 0)]
|
|
||||||
[string]$Name,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'ByID')]
|
|
||||||
[uint64[]]$Id,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[string]$Query,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[string]$Email,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[string]$Title,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[string]$Phone,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[string]$Address,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[string]$Group,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[uint64]$GroupID,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[uint16]$Limit,
|
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
|
||||||
[uint16]$Offset,
|
|
||||||
|
|
||||||
[switch]$Raw
|
|
||||||
)
|
|
||||||
|
|
||||||
switch ($PSCmdlet.ParameterSetName) {
|
|
||||||
'ById' {
|
|
||||||
foreach ($Contact_ID in $Id) {
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contacts', $Contact_ID))
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
|
||||||
}
|
|
||||||
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
default {
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contacts'))
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
|
||||||
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,99 +0,0 @@
|
||||||
|
|
||||||
function New-NetboxContact {
|
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Create a new contact in Netbox
|
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
Creates a new contact object in Netbox which can be linked to other objects
|
|
||||||
|
|
||||||
.PARAMETER Name
|
|
||||||
The contacts full name, e.g "Leroy Jenkins"
|
|
||||||
|
|
||||||
.PARAMETER Email
|
|
||||||
Email address of the contact
|
|
||||||
|
|
||||||
.PARAMETER Title
|
|
||||||
Job title or other title related to the contact
|
|
||||||
|
|
||||||
.PARAMETER Phone
|
|
||||||
Telephone number
|
|
||||||
|
|
||||||
.PARAMETER Address
|
|
||||||
Physical address, usually mailing address
|
|
||||||
|
|
||||||
.PARAMETER Description
|
|
||||||
Short description of the contact
|
|
||||||
|
|
||||||
.PARAMETER Comments
|
|
||||||
Detailed comments. Markdown supported.
|
|
||||||
|
|
||||||
.PARAMETER Link
|
|
||||||
URI related to the contact
|
|
||||||
|
|
||||||
.PARAMETER Custom_Fields
|
|
||||||
A description of the Custom_Fields parameter.
|
|
||||||
|
|
||||||
.PARAMETER Raw
|
|
||||||
A description of the Raw parameter.
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
PS C:\> New-NetboxContact -Name 'Leroy Jenkins' -Email 'leroy.jenkins@example.com'
|
|
||||||
|
|
||||||
.NOTES
|
|
||||||
Additional information about the function.
|
|
||||||
#>
|
|
||||||
|
|
||||||
[CmdletBinding(ConfirmImpact = 'Low',
|
|
||||||
SupportsShouldProcess = $true)]
|
|
||||||
[OutputType([pscustomobject])]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[Parameter(Mandatory = $true,
|
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
|
||||||
[ValidateLength(1, 100)]
|
|
||||||
[string]$Name,
|
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[ValidateLength(0, 254)]
|
|
||||||
[string]$Email,
|
|
||||||
|
|
||||||
[ValidateLength(0, 100)]
|
|
||||||
[string]$Title,
|
|
||||||
|
|
||||||
[ValidateLength(0, 50)]
|
|
||||||
[string]$Phone,
|
|
||||||
|
|
||||||
[ValidateLength(0, 200)]
|
|
||||||
[string]$Address,
|
|
||||||
|
|
||||||
[ValidateLength(0, 200)]
|
|
||||||
[string]$Description,
|
|
||||||
|
|
||||||
[string]$Comments,
|
|
||||||
|
|
||||||
[ValidateLength(0, 200)]
|
|
||||||
[string]$Link,
|
|
||||||
|
|
||||||
[hashtable]$Custom_Fields,
|
|
||||||
|
|
||||||
[switch]$Raw
|
|
||||||
)
|
|
||||||
|
|
||||||
process {
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contacts'))
|
|
||||||
$Method = 'POST'
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
|
||||||
|
|
||||||
if ($PSCmdlet.ShouldProcess($Name, 'Create new contact')) {
|
|
||||||
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,120 +0,0 @@
|
||||||
|
|
||||||
function Set-NetboxContact {
|
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Update a contact in Netbox
|
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
Updates a contact object in Netbox which can be linked to other objects
|
|
||||||
|
|
||||||
.PARAMETER Id
|
|
||||||
A description of the Id parameter.
|
|
||||||
|
|
||||||
.PARAMETER Name
|
|
||||||
The contacts full name, e.g "Leroy Jenkins"
|
|
||||||
|
|
||||||
.PARAMETER Email
|
|
||||||
Email address of the contact
|
|
||||||
|
|
||||||
.PARAMETER Group
|
|
||||||
Database ID of assigned group
|
|
||||||
|
|
||||||
.PARAMETER Title
|
|
||||||
Job title or other title related to the contact
|
|
||||||
|
|
||||||
.PARAMETER Phone
|
|
||||||
Telephone number
|
|
||||||
|
|
||||||
.PARAMETER Address
|
|
||||||
Physical address, usually mailing address
|
|
||||||
|
|
||||||
.PARAMETER Description
|
|
||||||
Short description of the contact
|
|
||||||
|
|
||||||
.PARAMETER Comments
|
|
||||||
Detailed comments. Markdown supported.
|
|
||||||
|
|
||||||
.PARAMETER Link
|
|
||||||
URI related to the contact
|
|
||||||
|
|
||||||
.PARAMETER Custom_Fields
|
|
||||||
A description of the Custom_Fields parameter.
|
|
||||||
|
|
||||||
.PARAMETER Force
|
|
||||||
A description of the Force parameter.
|
|
||||||
|
|
||||||
.PARAMETER Raw
|
|
||||||
A description of the Raw parameter.
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
PS C:\> Set-NetboxContact -Id 10 -Name 'Leroy Jenkins' -Email 'leroy.jenkins@example.com'
|
|
||||||
|
|
||||||
.NOTES
|
|
||||||
Additional information about the function.
|
|
||||||
#>
|
|
||||||
|
|
||||||
[CmdletBinding(ConfirmImpact = 'Low',
|
|
||||||
SupportsShouldProcess = $true)]
|
|
||||||
[OutputType([pscustomobject])]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[Parameter(Mandatory = $true,
|
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
|
||||||
[uint64[]]$Id,
|
|
||||||
|
|
||||||
[ValidateLength(1, 100)]
|
|
||||||
[string]$Name,
|
|
||||||
|
|
||||||
[ValidateLength(0, 254)]
|
|
||||||
[string]$Email,
|
|
||||||
|
|
||||||
[uint64]$Group,
|
|
||||||
|
|
||||||
[ValidateLength(0, 100)]
|
|
||||||
[string]$Title,
|
|
||||||
|
|
||||||
[ValidateLength(0, 50)]
|
|
||||||
[string]$Phone,
|
|
||||||
|
|
||||||
[ValidateLength(0, 200)]
|
|
||||||
[string]$Address,
|
|
||||||
|
|
||||||
[ValidateLength(0, 200)]
|
|
||||||
[string]$Description,
|
|
||||||
|
|
||||||
[string]$Comments,
|
|
||||||
|
|
||||||
[ValidateLength(0, 200)]
|
|
||||||
[string]$Link,
|
|
||||||
|
|
||||||
[hashtable]$Custom_Fields,
|
|
||||||
|
|
||||||
[switch]$Force,
|
|
||||||
|
|
||||||
[switch]$Raw
|
|
||||||
)
|
|
||||||
|
|
||||||
begin {
|
|
||||||
$Method = 'PATCH'
|
|
||||||
}
|
|
||||||
|
|
||||||
process {
|
|
||||||
foreach ($ContactId in $Id) {
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contacts', $ContactId))
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
|
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
|
||||||
|
|
||||||
$CurrentContact = Get-NetboxContact -Id $ContactId -ErrorAction Stop
|
|
||||||
|
|
||||||
if ($Force -or $PSCmdlet.ShouldProcess($CurrentContact.Name, 'Update contact')) {
|
|
||||||
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,107 +1,120 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/19/2020 11:56
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Get-NetboxTenant.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxTenant {
|
function Get-NetboxTenant {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Get a tenent from Netbox
|
Get a tenent from Netbox
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
A detailed description of the Get-NetboxTenant function.
|
A detailed description of the Get-NetboxTenant function.
|
||||||
|
|
||||||
.PARAMETER Name
|
.PARAMETER Name
|
||||||
The specific name of the tenant. Must match exactly as is defined in Netbox
|
The specific name of the tenant. Must match exactly as is defined in Netbox
|
||||||
|
|
||||||
.PARAMETER Id
|
.PARAMETER Id
|
||||||
The database ID of the tenant
|
The database ID of the tenant
|
||||||
|
|
||||||
.PARAMETER Query
|
.PARAMETER Query
|
||||||
A standard search query that will match one or more tenants.
|
A standard search query that will match one or more tenants.
|
||||||
|
|
||||||
.PARAMETER Slug
|
.PARAMETER Slug
|
||||||
The specific slug of the tenant. Must match exactly as is defined in Netbox
|
The specific slug of the tenant. Must match exactly as is defined in Netbox
|
||||||
|
|
||||||
.PARAMETER Group
|
.PARAMETER Group
|
||||||
The specific group as defined in Netbox.
|
The specific group as defined in Netbox.
|
||||||
|
|
||||||
.PARAMETER GroupID
|
.PARAMETER GroupID
|
||||||
The database ID of the group in Netbox
|
The database ID of the group in Netbox
|
||||||
|
|
||||||
.PARAMETER CustomFields
|
.PARAMETER CustomFields
|
||||||
Hashtable in the format @{"field_name" = "value"} to search
|
Hashtable in the format @{"field_name" = "value"} to search
|
||||||
|
|
||||||
.PARAMETER Limit
|
.PARAMETER Limit
|
||||||
Limit the number of results to this number
|
Limit the number of results to this number
|
||||||
|
|
||||||
.PARAMETER Offset
|
.PARAMETER Offset
|
||||||
Start the search at this index in results
|
Start the search at this index in results
|
||||||
|
|
||||||
.PARAMETER Raw
|
.PARAMETER Raw
|
||||||
Return the unparsed data from the HTTP request
|
Return the unparsed data from the HTTP request
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> Get-NetboxTenant
|
PS C:\> Get-NetboxTenant
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Additional information about the function.
|
Additional information about the function.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(ParameterSetName = 'Query',
|
[Parameter(ParameterSetName = 'Query',
|
||||||
Position = 0)]
|
Position = 0)]
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'ByID')]
|
[Parameter(ParameterSetName = 'ByID')]
|
||||||
[uint64[]]$Id,
|
[uint32[]]$Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Query,
|
[string]$Query,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Slug,
|
[string]$Slug,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Group,
|
[string]$Group,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint64]$GroupID,
|
[uint16]$GroupID,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[hashtable]$CustomFields,
|
[hashtable]$CustomFields,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint16]$Limit,
|
[uint16]$Limit,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint16]$Offset,
|
[uint16]$Offset,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
switch ($PSCmdlet.ParameterSetName) {
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
'ById' {
|
'ById' {
|
||||||
foreach ($Tenant_ID in $Id) {
|
foreach ($Tenant_ID in $Id) {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'tenants', $Tenant_ID))
|
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'tenants', $Tenant_ID))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
}
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
default {
|
default {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'tenants'))
|
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'tenants'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
36
Functions/Tenancy/Tenancy.ps1
Normal file
36
Functions/Tenancy/Tenancy.ps1
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2018 v5.5.152
|
||||||
|
Created on: 5/29/2018 1:45 PM
|
||||||
|
Created by: Ben Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Tenancy.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region GET commands
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endregion GET commands
|
||||||
|
|
||||||
|
|
||||||
|
#region SET commands
|
||||||
|
|
||||||
|
#endregion SET commands
|
||||||
|
|
||||||
|
|
||||||
|
#region ADD/NEW commands
|
||||||
|
|
||||||
|
#endregion ADD/NEW commands
|
||||||
|
|
||||||
|
|
||||||
|
#region REMOVE commands
|
||||||
|
|
||||||
|
#endregion REMOVE commands
|
||||||
|
|
@ -1,71 +0,0 @@
|
||||||
|
|
||||||
function New-NetboxTenant {
|
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Create a new tenant in Netbox
|
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
Creates a new tenant object in Netbox
|
|
||||||
|
|
||||||
.PARAMETER Name
|
|
||||||
The tenant name, e.g "Contoso Inc"
|
|
||||||
|
|
||||||
.PARAMETER Slug
|
|
||||||
The unique URL for the tenant. Can only contain hypens, A-Z, a-z, 0-9, and underscores
|
|
||||||
|
|
||||||
.PARAMETER Description
|
|
||||||
Short description of the tenant
|
|
||||||
|
|
||||||
.PARAMETER Custom_Fields
|
|
||||||
Hashtable of custom field values.
|
|
||||||
|
|
||||||
.PARAMETER Raw
|
|
||||||
Return the unparsed data from the HTTP request
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
PS C:\> New-NetboxTenant -Name 'Contoso Inc' -Slug 'contoso-inc'
|
|
||||||
|
|
||||||
.NOTES
|
|
||||||
Additional information about the function.
|
|
||||||
#>
|
|
||||||
|
|
||||||
[CmdletBinding(ConfirmImpact = 'Low',
|
|
||||||
SupportsShouldProcess = $true)]
|
|
||||||
[OutputType([pscustomobject])]
|
|
||||||
param
|
|
||||||
(
|
|
||||||
[Parameter(Mandatory = $true,
|
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
|
||||||
[ValidateLength(1, 100)]
|
|
||||||
[string]$Name,
|
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[ValidateLength(1, 100)]
|
|
||||||
[ValidatePattern('^[-a-zA-Z0-9_]+$')]
|
|
||||||
[string]$Slug,
|
|
||||||
|
|
||||||
[ValidateLength(0, 200)]
|
|
||||||
[string]$Description,
|
|
||||||
|
|
||||||
[hashtable]$Custom_Fields,
|
|
||||||
|
|
||||||
[switch]$Raw
|
|
||||||
)
|
|
||||||
|
|
||||||
process {
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'tenants'))
|
|
||||||
$Method = 'POST'
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
|
||||||
|
|
||||||
if ($PSCmdlet.ShouldProcess($Address, 'Create new tenant')) {
|
|
||||||
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,144 +1,155 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/19/2020 12:44
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Get-NetboxVirtualMachine.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxVirtualMachine {
|
function Get-NetboxVirtualMachine {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Obtains virtual machines from Netbox.
|
Obtains virtual machines from Netbox.
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Obtains one or more virtual machines based on provided filters.
|
Obtains one or more virtual machines based on provided filters.
|
||||||
|
|
||||||
.PARAMETER Limit
|
.PARAMETER Limit
|
||||||
Number of results to return per page
|
Number of results to return per page
|
||||||
|
|
||||||
.PARAMETER Offset
|
.PARAMETER Offset
|
||||||
The initial index from which to return the results
|
The initial index from which to return the results
|
||||||
|
|
||||||
.PARAMETER Query
|
.PARAMETER Query
|
||||||
A general query used to search for a VM
|
A general query used to search for a VM
|
||||||
|
|
||||||
.PARAMETER Name
|
.PARAMETER Name
|
||||||
Name of the VM
|
Name of the VM
|
||||||
|
|
||||||
.PARAMETER Id
|
.PARAMETER Id
|
||||||
Database ID of the VM
|
Database ID of the VM
|
||||||
|
|
||||||
.PARAMETER Status
|
.PARAMETER Status
|
||||||
Status of the VM
|
Status of the VM
|
||||||
|
|
||||||
.PARAMETER Tenant
|
.PARAMETER Tenant
|
||||||
String value of tenant
|
String value of tenant
|
||||||
|
|
||||||
.PARAMETER Tenant_ID
|
.PARAMETER Tenant_ID
|
||||||
Database ID of the tenant.
|
Database ID of the tenant.
|
||||||
|
|
||||||
.PARAMETER Platform
|
.PARAMETER Platform
|
||||||
String value of the platform
|
String value of the platform
|
||||||
|
|
||||||
.PARAMETER Platform_ID
|
.PARAMETER Platform_ID
|
||||||
Database ID of the platform
|
Database ID of the platform
|
||||||
|
|
||||||
.PARAMETER Cluster_Group
|
.PARAMETER Cluster_Group
|
||||||
String value of the cluster group.
|
String value of the cluster group.
|
||||||
|
|
||||||
.PARAMETER Cluster_Group_Id
|
.PARAMETER Cluster_Group_Id
|
||||||
Database ID of the cluster group.
|
Database ID of the cluster group.
|
||||||
|
|
||||||
.PARAMETER Cluster_Type
|
.PARAMETER Cluster_Type
|
||||||
String value of the Cluster type.
|
String value of the Cluster type.
|
||||||
|
|
||||||
.PARAMETER Cluster_Type_Id
|
.PARAMETER Cluster_Type_Id
|
||||||
Database ID of the cluster type.
|
Database ID of the cluster type.
|
||||||
|
|
||||||
.PARAMETER Cluster_Id
|
.PARAMETER Cluster_Id
|
||||||
Database ID of the cluster.
|
Database ID of the cluster.
|
||||||
|
|
||||||
.PARAMETER Site
|
.PARAMETER Site
|
||||||
String value of the site.
|
String value of the site.
|
||||||
|
|
||||||
.PARAMETER Site_Id
|
.PARAMETER Site_Id
|
||||||
Database ID of the site.
|
Database ID of the site.
|
||||||
|
|
||||||
.PARAMETER Role
|
.PARAMETER Role
|
||||||
String value of the role.
|
String value of the role.
|
||||||
|
|
||||||
.PARAMETER Role_Id
|
.PARAMETER Role_Id
|
||||||
Database ID of the role.
|
Database ID of the role.
|
||||||
|
|
||||||
.PARAMETER Raw
|
.PARAMETER Raw
|
||||||
A description of the Raw parameter.
|
A description of the Raw parameter.
|
||||||
|
|
||||||
.PARAMETER TenantID
|
.PARAMETER TenantID
|
||||||
Database ID of tenant
|
Database ID of tenant
|
||||||
|
|
||||||
.PARAMETER PlatformID
|
.PARAMETER PlatformID
|
||||||
Database ID of the platform
|
Database ID of the platform
|
||||||
|
|
||||||
.PARAMETER id__in
|
.PARAMETER id__in
|
||||||
Database IDs of VMs
|
Database IDs of VMs
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> Get-NetboxVirtualMachine
|
PS C:\> Get-NetboxVirtualMachine
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Additional information about the function.
|
Additional information about the function.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Alias('q')]
|
[Alias('q')]
|
||||||
[string]$Query,
|
[string]$Query,
|
||||||
|
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[uint64[]]$Id,
|
[uint16[]]$Id,
|
||||||
|
|
||||||
[object]$Status,
|
[object]$Status,
|
||||||
|
|
||||||
[string]$Tenant,
|
[string]$Tenant,
|
||||||
|
|
||||||
[uint64]$Tenant_ID,
|
[uint16]$Tenant_ID,
|
||||||
|
|
||||||
[string]$Platform,
|
[string]$Platform,
|
||||||
|
|
||||||
[uint64]$Platform_ID,
|
[uint16]$Platform_ID,
|
||||||
|
|
||||||
[string]$Cluster_Group,
|
[string]$Cluster_Group,
|
||||||
|
|
||||||
[uint64]$Cluster_Group_Id,
|
[uint16]$Cluster_Group_Id,
|
||||||
|
|
||||||
[string]$Cluster_Type,
|
[string]$Cluster_Type,
|
||||||
|
|
||||||
[uint64]$Cluster_Type_Id,
|
[uint16]$Cluster_Type_Id,
|
||||||
|
|
||||||
[uint64]$Cluster_Id,
|
[uint16]$Cluster_Id,
|
||||||
|
|
||||||
[string]$Site,
|
[string]$Site,
|
||||||
|
|
||||||
[uint64]$Site_Id,
|
[uint16]$Site_Id,
|
||||||
|
|
||||||
[string]$Role,
|
[string]$Role,
|
||||||
|
|
||||||
[uint64]$Role_Id,
|
[uint16]$Role_Id,
|
||||||
|
|
||||||
[uint16]$Limit,
|
[uint16]$Limit,
|
||||||
|
|
||||||
[uint16]$Offset,
|
[uint16]$Offset,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
process {
|
if ($null -ne $Status) {
|
||||||
if ($null -ne $Status) {
|
$PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
|
||||||
$PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
|
|
||||||
}
|
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines'))
|
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
}
|
}
|
||||||
|
|
@ -1,63 +1,67 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/19/2020 12:44
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: New-NetboxVirtualMachine.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function New-NetboxVirtualMachine {
|
function New-NetboxVirtualMachine {
|
||||||
[CmdletBinding(ConfirmImpact = 'low',
|
[CmdletBinding()]
|
||||||
SupportsShouldProcess = $true)]
|
|
||||||
[OutputType([pscustomobject])]
|
[OutputType([pscustomobject])]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[uint64]$Site,
|
[uint16]$Cluster,
|
||||||
|
|
||||||
[uint64]$Cluster,
|
[uint16]$Tenant,
|
||||||
|
|
||||||
[uint64]$Tenant,
|
|
||||||
|
|
||||||
[object]$Status = 'Active',
|
[object]$Status = 'Active',
|
||||||
|
|
||||||
[uint64]$Role,
|
[uint16]$Role,
|
||||||
|
|
||||||
[uint64]$Platform,
|
[uint16]$Platform,
|
||||||
|
|
||||||
[uint16]$vCPUs,
|
[uint16]$vCPUs,
|
||||||
|
|
||||||
[uint64]$Memory,
|
[uint16]$Memory,
|
||||||
|
|
||||||
[uint64]$Disk,
|
[uint16]$Disk,
|
||||||
|
|
||||||
[uint64]$Primary_IP4,
|
[uint16]$Primary_IP4,
|
||||||
|
|
||||||
[uint64]$Primary_IP6,
|
[uint16]$Primary_IP6,
|
||||||
|
|
||||||
[hashtable]$Custom_Fields,
|
[hashtable]$Custom_Fields,
|
||||||
|
|
||||||
[string]$Comments
|
[string]$Comments
|
||||||
)
|
)
|
||||||
|
|
||||||
# $ModelDefinition = $script:NetboxConfig.APIDefinition.definitions.WritableVirtualMachineWithConfigContext
|
# $ModelDefinition = $script:NetboxConfig.APIDefinition.definitions.WritableVirtualMachineWithConfigContext
|
||||||
|
#
|
||||||
# # Validate the status against the APIDefinition
|
# # Validate the status against the APIDefinition
|
||||||
# if ($ModelDefinition.properties.status.enum -inotcontains $Status) {
|
# if ($ModelDefinition.properties.status.enum -inotcontains $Status) {
|
||||||
# throw ("Invalid value [] for Status. Must be one of []" -f $Status, ($ModelDefinition.properties.status.enum -join ', '))
|
# throw ("Invalid value [] for Status. Must be one of []" -f $Status, ($ModelDefinition.properties.status.enum -join ', '))
|
||||||
# }
|
# }
|
||||||
|
#
|
||||||
#$PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
|
#$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"
|
|
||||||
}
|
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines'))
|
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
if ($PSCmdlet.ShouldProcess($name, 'Create new Virtual Machine')) {
|
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters
|
||||||
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,55 +1,68 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/19/2020 12:45
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Remove-NetboxVirtualMachine.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function Remove-NetboxVirtualMachine {
|
function Remove-NetboxVirtualMachine {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Delete a virtual machine
|
Delete a virtual machine
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Deletes a virtual machine from Netbox by ID
|
Deletes a virtual machine from Netbox by ID
|
||||||
|
|
||||||
.PARAMETER Id
|
.PARAMETER Id
|
||||||
Database ID of the virtual machine
|
Database ID of the virtual machine
|
||||||
|
|
||||||
.PARAMETER Force
|
.PARAMETER Force
|
||||||
Force deletion without any prompts
|
Force deletion without any prompts
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> Remove-NetboxVirtualMachine -Id $value1
|
PS C:\> Remove-NetboxVirtualMachine -Id $value1
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Additional information about the function.
|
Additional information about the function.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding(ConfirmImpact = 'High',
|
[CmdletBinding(ConfirmImpact = 'High',
|
||||||
SupportsShouldProcess = $true)]
|
SupportsShouldProcess = $true)]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true,
|
[Parameter(Mandatory = $true,
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[uint64[]]$Id,
|
[uint16[]]$Id,
|
||||||
|
|
||||||
[switch]$Force
|
[switch]$Force
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
foreach ($VMId in $Id) {
|
foreach ($VMId in $Id) {
|
||||||
$CurrentVM = Get-NetboxVirtualMachine -Id $VMId -ErrorAction Stop
|
$CurrentVM = Get-NetboxVirtualMachine -Id $VMId -ErrorAction Stop
|
||||||
|
|
||||||
if ($Force -or $pscmdlet.ShouldProcess("$($CurrentVM.Name)/$($CurrentVM.Id)", "Remove")) {
|
if ($Force -or $pscmdlet.ShouldProcess("$($CurrentVM.Name)/$($CurrentVM.Id)", "Remove")) {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines', $CurrentVM.Id))
|
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines', $CurrentVM.Id))
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $Segments
|
$URI = BuildNewURI -Segments $Segments
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Method DELETE
|
InvokeNetboxRequest -URI $URI -Method DELETE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
end {
|
end {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,61 +1,72 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/19/2020 12:45
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Set-NetboxVirtualMachine.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function Set-NetboxVirtualMachine {
|
function Set-NetboxVirtualMachine {
|
||||||
[CmdletBinding(ConfirmImpact = 'Medium',
|
[CmdletBinding(ConfirmImpact = 'Medium',
|
||||||
SupportsShouldProcess = $true)]
|
SupportsShouldProcess = $true)]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true,
|
[Parameter(Mandatory = $true,
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[uint64]$Id,
|
[uint16]$Id,
|
||||||
|
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[uint64]$Role,
|
[uint16]$Role,
|
||||||
|
|
||||||
[uint64]$Cluster,
|
[uint16]$Cluster,
|
||||||
|
|
||||||
[object]$Status,
|
[object]$Status,
|
||||||
|
|
||||||
[uint64]$Platform,
|
[uint16]$Platform,
|
||||||
|
|
||||||
[uint64]$Primary_IP4,
|
[uint16]$Primary_IP4,
|
||||||
|
|
||||||
[uint64]$Primary_IP6,
|
[uint16]$Primary_IP6,
|
||||||
|
|
||||||
[byte]$VCPUs,
|
[byte]$VCPUs,
|
||||||
|
|
||||||
[uint64]$Memory,
|
[uint16]$Memory,
|
||||||
|
|
||||||
[uint64]$Disk,
|
[uint16]$Disk,
|
||||||
|
|
||||||
[uint64]$Tenant,
|
[uint16]$Tenant,
|
||||||
|
|
||||||
[string]$Comments,
|
[string]$Comments,
|
||||||
|
|
||||||
[hashtable]$Custom_Fields,
|
[hashtable]$Custom_Fields,
|
||||||
|
|
||||||
[switch]$Force
|
[switch]$Force
|
||||||
)
|
)
|
||||||
|
|
||||||
# if ($null -ne $Status) {
|
# if ($null -ne $Status) {
|
||||||
# $PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
|
# $PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
|
||||||
# }
|
# }
|
||||||
|
#
|
||||||
process {
|
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines', $Id))
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines', $Id))
|
|
||||||
|
Write-Verbose "Obtaining VM from ID $Id"
|
||||||
Write-Verbose "Obtaining VM from ID $Id"
|
|
||||||
|
#$CurrentVM = Get-NetboxVirtualMachine -Id $Id -ErrorAction Stop
|
||||||
#$CurrentVM = Get-NetboxVirtualMachine -Id $Id -ErrorAction Stop
|
|
||||||
|
Write-Verbose "Finished obtaining VM"
|
||||||
Write-Verbose "Finished obtaining VM"
|
|
||||||
|
if ($Force -or $pscmdlet.ShouldProcess($ID, "Set properties on VM ID")) {
|
||||||
if ($Force -or $pscmdlet.ShouldProcess($ID, "Set properties on VM ID")) {
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
|
||||||
|
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
|
||||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,32 +1,45 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/19/2020 12:46
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Add-NetboxVirtualMachineInterface.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function Add-NetboxVirtualMachineInterface {
|
function Add-NetboxVirtualMachineInterface {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[uint64]$Virtual_Machine,
|
[uint16]$Virtual_Machine,
|
||||||
|
|
||||||
[boolean]$Enabled = $true,
|
[boolean]$Enabled = $true,
|
||||||
|
|
||||||
[string]$MAC_Address,
|
[string]$MAC_Address,
|
||||||
|
|
||||||
[uint16]$MTU,
|
[uint16]$MTU,
|
||||||
|
|
||||||
[string]$Description,
|
[string]$Description,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'interfaces'))
|
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'interfaces'))
|
||||||
|
|
||||||
$PSBoundParameters.Enabled = $Enabled
|
$PSBoundParameters.Enabled = $Enabled
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments
|
$uri = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Method POST -Body $URIComponents.Parameters
|
InvokeNetboxRequest -URI $uri -Method POST -Body $URIComponents.Parameters
|
||||||
}
|
}
|
||||||
|
|
@ -1,83 +1,94 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/19/2020 12:47
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Get-NetboxVirtualMachineInterface.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxVirtualMachineInterface {
|
function Get-NetboxVirtualMachineInterface {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Gets VM interfaces
|
Gets VM interfaces
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Obtains the interface objects for one or more VMs
|
Obtains the interface objects for one or more VMs
|
||||||
|
|
||||||
.PARAMETER Limit
|
.PARAMETER Limit
|
||||||
Number of results to return per page.
|
Number of results to return per page.
|
||||||
|
|
||||||
.PARAMETER Offset
|
.PARAMETER Offset
|
||||||
The initial index from which to return the results.
|
The initial index from which to return the results.
|
||||||
|
|
||||||
.PARAMETER Id
|
.PARAMETER Id
|
||||||
Database ID of the interface
|
Database ID of the interface
|
||||||
|
|
||||||
.PARAMETER Name
|
.PARAMETER Name
|
||||||
Name of the interface
|
Name of the interface
|
||||||
|
|
||||||
.PARAMETER Enabled
|
.PARAMETER Enabled
|
||||||
True/False if the interface is enabled
|
True/False if the interface is enabled
|
||||||
|
|
||||||
.PARAMETER MTU
|
.PARAMETER MTU
|
||||||
Maximum Transmission Unit size. Generally 1500 or 9000
|
Maximum Transmission Unit size. Generally 1500 or 9000
|
||||||
|
|
||||||
.PARAMETER Virtual_Machine_Id
|
.PARAMETER Virtual_Machine_Id
|
||||||
ID of the virtual machine to which the interface(s) are assigned.
|
ID of the virtual machine to which the interface(s) are assigned.
|
||||||
|
|
||||||
.PARAMETER Virtual_Machine
|
.PARAMETER Virtual_Machine
|
||||||
Name of the virtual machine to get interfaces
|
Name of the virtual machine to get interfaces
|
||||||
|
|
||||||
.PARAMETER MAC_Address
|
.PARAMETER MAC_Address
|
||||||
MAC address assigned to the interface
|
MAC address assigned to the interface
|
||||||
|
|
||||||
.PARAMETER Raw
|
.PARAMETER Raw
|
||||||
A description of the Raw parameter.
|
A description of the Raw parameter.
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> Get-NetboxVirtualMachineInterface
|
PS C:\> Get-NetboxVirtualMachineInterface
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Additional information about the function.
|
Additional information about the function.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(ValueFromPipeline = $true)]
|
[Parameter(ValueFromPipeline = $true)]
|
||||||
[uint64]$Id,
|
[uint16]$Id,
|
||||||
|
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[string]$Query,
|
[string]$Query,
|
||||||
|
|
||||||
[boolean]$Enabled,
|
[boolean]$Enabled,
|
||||||
|
|
||||||
[uint16]$MTU,
|
[uint16]$MTU,
|
||||||
|
|
||||||
[uint64]$Virtual_Machine_Id,
|
[uint16]$Virtual_Machine_Id,
|
||||||
|
|
||||||
[string]$Virtual_Machine,
|
[string]$Virtual_Machine,
|
||||||
|
|
||||||
[string]$MAC_Address,
|
[string]$MAC_Address,
|
||||||
|
|
||||||
[uint16]$Limit,
|
[uint16]$Limit,
|
||||||
|
|
||||||
[uint16]$Offset,
|
[uint16]$Offset,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
process {
|
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'interfaces'))
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'interfaces'))
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
|
||||||
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
|
||||||
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,17 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/19/2020 12:47
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Set-NetboxVirtualMachineInterface.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function Set-NetboxVirtualMachineInterface {
|
function Set-NetboxVirtualMachineInterface {
|
||||||
[CmdletBinding(ConfirmImpact = 'Medium',
|
[CmdletBinding(ConfirmImpact = 'Medium',
|
||||||
SupportsShouldProcess = $true)]
|
SupportsShouldProcess = $true)]
|
||||||
|
|
@ -7,46 +20,46 @@ function Set-NetboxVirtualMachineInterface {
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true,
|
[Parameter(Mandatory = $true,
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[uint64[]]$Id,
|
[uint16[]]$Id,
|
||||||
|
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[string]$MAC_Address,
|
[string]$MAC_Address,
|
||||||
|
|
||||||
[uint16]$MTU,
|
[uint16]$MTU,
|
||||||
|
|
||||||
[string]$Description,
|
[string]$Description,
|
||||||
|
|
||||||
[boolean]$Enabled,
|
[boolean]$Enabled,
|
||||||
|
|
||||||
[uint64]$Virtual_Machine,
|
[uint16]$Virtual_Machine,
|
||||||
|
|
||||||
[switch]$Force
|
[switch]$Force
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
foreach ($VMI_ID in $Id) {
|
foreach ($VMI_ID in $Id) {
|
||||||
Write-Verbose "Obtaining VM Interface..."
|
Write-Verbose "Obtaining VM Interface..."
|
||||||
$CurrentVMI = Get-NetboxVirtualMachineInterface -Id $VMI_ID -ErrorAction Stop
|
$CurrentVMI = Get-NetboxVirtualMachineInterface -Id $VMI_ID -ErrorAction Stop
|
||||||
Write-Verbose "Finished obtaining VM Interface"
|
Write-Verbose "Finished obtaining VM Interface"
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'interfaces', $CurrentVMI.Id))
|
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'interfaces', $CurrentVMI.Id))
|
||||||
|
|
||||||
if ($Force -or $pscmdlet.ShouldProcess("Interface $($CurrentVMI.Id) on VM $($CurrentVMI.Virtual_Machine.Name)", "Set")) {
|
if ($Force -or $pscmdlet.ShouldProcess("Interface $($CurrentVMI.Id) on VM $($CurrentVMI.Virtual_Machine.Name)", "Set")) {
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
|
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
end {
|
end {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,89 +1,102 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/19/2020 14:10
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Get-NetboxVirtualizationCluster.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxVirtualizationCluster {
|
function Get-NetboxVirtualizationCluster {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Obtains virtualization clusters from Netbox.
|
Obtains virtualization clusters from Netbox.
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Obtains one or more virtualization clusters based on provided filters.
|
Obtains one or more virtualization clusters based on provided filters.
|
||||||
|
|
||||||
.PARAMETER Limit
|
.PARAMETER Limit
|
||||||
Number of results to return per page
|
Number of results to return per page
|
||||||
|
|
||||||
.PARAMETER Offset
|
.PARAMETER Offset
|
||||||
The initial index from which to return the results
|
The initial index from which to return the results
|
||||||
|
|
||||||
.PARAMETER Query
|
.PARAMETER Query
|
||||||
A general query used to search for a cluster
|
A general query used to search for a cluster
|
||||||
|
|
||||||
.PARAMETER Name
|
.PARAMETER Name
|
||||||
Name of the cluster
|
Name of the cluster
|
||||||
|
|
||||||
.PARAMETER Id
|
.PARAMETER Id
|
||||||
Database ID(s) of the cluster
|
Database ID(s) of the cluster
|
||||||
|
|
||||||
.PARAMETER Group
|
.PARAMETER Group
|
||||||
String value of the cluster group.
|
String value of the cluster group.
|
||||||
|
|
||||||
.PARAMETER Group_Id
|
.PARAMETER Group_Id
|
||||||
Database ID of the cluster group.
|
Database ID of the cluster group.
|
||||||
|
|
||||||
.PARAMETER Type
|
.PARAMETER Type
|
||||||
String value of the Cluster type.
|
String value of the Cluster type.
|
||||||
|
|
||||||
.PARAMETER Type_Id
|
.PARAMETER Type_Id
|
||||||
Database ID of the cluster type.
|
Database ID of the cluster type.
|
||||||
|
|
||||||
.PARAMETER Site
|
.PARAMETER Site
|
||||||
String value of the site.
|
String value of the site.
|
||||||
|
|
||||||
.PARAMETER Site_Id
|
.PARAMETER Site_Id
|
||||||
Database ID of the site.
|
Database ID of the site.
|
||||||
|
|
||||||
.PARAMETER Raw
|
.PARAMETER Raw
|
||||||
A description of the Raw parameter.
|
A description of the Raw parameter.
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> Get-NetboxVirtualizationCluster
|
PS C:\> Get-NetboxVirtualizationCluster
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Additional information about the function.
|
Additional information about the function.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[Alias('q')]
|
[Alias('q')]
|
||||||
[string]$Query,
|
[string]$Query,
|
||||||
|
|
||||||
[uint64[]]$Id,
|
[uint16[]]$Id,
|
||||||
|
|
||||||
[string]$Group,
|
[string]$Group,
|
||||||
|
|
||||||
[uint64]$Group_Id,
|
[uint16]$Group_Id,
|
||||||
|
|
||||||
[string]$Type,
|
[string]$Type,
|
||||||
|
|
||||||
[uint64]$Type_Id,
|
[uint16]$Type_Id,
|
||||||
|
|
||||||
[string]$Site,
|
[string]$Site,
|
||||||
|
|
||||||
[uint64]$Site_Id,
|
[uint16]$Site_Id,
|
||||||
|
|
||||||
[uint16]$Limit,
|
[uint16]$Limit,
|
||||||
|
|
||||||
[uint16]$Offset,
|
[uint16]$Offset,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'clusters'))
|
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'clusters'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
}
|
}
|
||||||
|
|
@ -1,30 +1,43 @@
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Created on: 3/19/2020 14:11
|
||||||
|
Created by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
Filename: Get-NetboxVirtualizationClusterGroup.ps1
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
A description of the file.
|
||||||
|
#>
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxVirtualizationClusterGroup {
|
function Get-NetboxVirtualizationClusterGroup {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[string]$Slug,
|
[string]$Slug,
|
||||||
|
|
||||||
[string]$Description,
|
[string]$Description,
|
||||||
|
|
||||||
[string]$Query,
|
[string]$Query,
|
||||||
|
|
||||||
[uint64[]]$Id,
|
[uint32[]]$Id,
|
||||||
|
|
||||||
[uint16]$Limit,
|
[uint16]$Limit,
|
||||||
|
|
||||||
[uint16]$Offset,
|
[uint16]$Offset,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'cluster-groups'))
|
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'cluster-groups'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
}
|
}
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
#
|
#
|
||||||
# Module manifest for module 'NetboxPS'
|
# Module manifest for module 'NetboxPS'
|
||||||
#
|
#
|
||||||
# Generated by: Ben Claussen
|
# Generated by: Ben Claussen
|
||||||
#
|
#
|
||||||
# Generated on: 2023-11-09
|
# Generated on: 2021-07-22
|
||||||
#
|
#
|
||||||
|
|
||||||
@{
|
@{
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
RootModule = 'NetboxPS.psm1'
|
RootModule = 'NetboxPS.psm1'
|
||||||
|
|
||||||
# Version number of this module.
|
# Version number of this module.
|
||||||
ModuleVersion = '1.8.5'
|
ModuleVersion = '1.4'
|
||||||
|
|
||||||
# Supported PSEditions
|
# Supported PSEditions
|
||||||
# CompatiblePSEditions = @()
|
# CompatiblePSEditions = @()
|
||||||
|
|
@ -54,7 +54,7 @@ CLRVersion = '2.0.50727'
|
||||||
# RequiredModules = @()
|
# RequiredModules = @()
|
||||||
|
|
||||||
# Assemblies that must be loaded prior to importing this module
|
# Assemblies that must be loaded prior to importing this module
|
||||||
# RequiredAssemblies = @()
|
RequiredAssemblies = 'System.Web'
|
||||||
|
|
||||||
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
|
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
|
||||||
# ScriptsToProcess = @()
|
# ScriptsToProcess = @()
|
||||||
|
|
@ -69,49 +69,7 @@ CLRVersion = '2.0.50727'
|
||||||
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.
|
# 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',
|
FunctionsToExport = '*'
|
||||||
'Add-NetboxDCIMInterfaceConnection', 'Add-NetboxDCIMRearPort',
|
|
||||||
'Add-NetboxVirtualMachineInterface', 'Clear-NetboxCredential',
|
|
||||||
'Connect-NetboxAPI', 'Get-ModelDefinition', 'Get-NetboxAPIDefinition',
|
|
||||||
'Get-NetboxCircuit', 'Get-NetboxCircuitProvider',
|
|
||||||
'Get-NetboxCircuitTermination', 'Get-NetboxCircuitType',
|
|
||||||
'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-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',
|
|
||||||
'Remove-NetboxDCIMInterfaceConnection', 'Remove-NetboxDCIMRearPort',
|
|
||||||
'Remove-NetboxDCIMSite', 'Remove-NetboxIPAMAddress',
|
|
||||||
'Remove-NetboxIPAMAddressRange', 'Remove-NetboxVirtualMachine',
|
|
||||||
'Set-NetboxCipherSSL', 'Set-NetboxContact',
|
|
||||||
'Set-NetboxContactAssignment', 'Set-NetboxContactRole',
|
|
||||||
'Set-NetboxCredential', 'Set-NetboxDCIMDevice',
|
|
||||||
'Set-NetboxDCIMFrontPort', 'Set-NetboxDCIMInterface',
|
|
||||||
'Set-NetboxDCIMInterfaceConnection', 'Set-NetboxDCIMRearPort',
|
|
||||||
'Set-NetboxHostName', 'Set-NetboxHostPort', 'Set-NetboxHostScheme',
|
|
||||||
'Set-NetboxInvokeParams', 'Set-NetboxIPAMAddress',
|
|
||||||
'Set-NetboxIPAMAddressRange', 'Set-NetboxIPAMPrefix',
|
|
||||||
'Set-NetboxTimeout', 'Set-NetboxUnstrustedSSL',
|
|
||||||
'Set-NetboxVirtualMachine', 'Set-NetboxVirtualMachineInterface',
|
|
||||||
'Test-NetboxAPIConnected'
|
|
||||||
|
|
||||||
# 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.
|
# 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 = '*'
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,22 @@
|
||||||
# Build a list of common parameters so we can omit them to build URI parameters
|
<#
|
||||||
|
.NOTES
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
Code generated by: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
Generated on: 3/26/2020 15:16
|
||||||
|
Generated by: Claussen
|
||||||
|
Organization: NEOnet
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
.DESCRIPTION
|
||||||
|
Script generated by PowerShell Studio 2020
|
||||||
|
#>
|
||||||
|
|
||||||
|
# Build a list of common paramters so we can omit them to build URI parameters
|
||||||
$script:CommonParameterNames = New-Object System.Collections.ArrayList
|
$script:CommonParameterNames = New-Object System.Collections.ArrayList
|
||||||
[void]$script:CommonParameterNames.AddRange(@([System.Management.Automation.PSCmdlet]::CommonParameters))
|
[void]$script:CommonParameterNames.AddRange(@([System.Management.Automation.PSCmdlet]::CommonParameters))
|
||||||
[void]$script:CommonParameterNames.AddRange(@([System.Management.Automation.PSCmdlet]::OptionalCommonParameters))
|
[void]$script:CommonParameterNames.AddRange(@([System.Management.Automation.PSCmdlet]::OptionalCommonParameters))
|
||||||
[void]$script:CommonParameterNames.Add('Raw')
|
[void]$script:CommonParameterNames.Add('Raw')
|
||||||
|
|
||||||
SetupNetboxConfigVariable
|
SetupNetboxConfigVariable
|
||||||
|
|
||||||
|
Export-ModuleMember -Function *
|
||||||
|
#Export-ModuleMember -Function *-*
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
<Project Synchronized="False" SyncFilter="*.ps1;*.psm1;*.psd1;*.ps1xml;*.psf;*.pss;*.xml;*.help.txt" AutoExportFunctions="True" ExportToLocalMachine="False" AutoExportPS1XMLFiles="False" StagingFolderName="bin">
|
<Project Synchronized="False" SyncFilter="*.ps1;*.psm1;*.psd1;*.ps1xml;*.psf;*.pss;*.xml;*.help.txt" AutoExportFunctions="True" AutoExportPS1XMLFiles="False">
|
||||||
<Version>2.1</Version>
|
<Version>2.1</Version>
|
||||||
<FileID>bba9b06c-49c8-47cf-8358-aca7c4e78896</FileID>
|
<FileID>bba9b06c-49c8-47cf-8358-aca7c4e78896</FileID>
|
||||||
<ProjectType>1</ProjectType>
|
<ProjectType>1</ProjectType>
|
||||||
<RememberPowerShellVersion>True</RememberPowerShellVersion>
|
|
||||||
<PowerShellVersion>Local Machine - PowerShell V5 (64 Bit)</PowerShellVersion>
|
|
||||||
<Folders>
|
<Folders>
|
||||||
<Folder>Functions</Folder>
|
<Folder>Functions</Folder>
|
||||||
<Folder>Functions\DCIM</Folder>
|
<Folder>Functions\DCIM</Folder>
|
||||||
|
|
@ -30,17 +28,6 @@
|
||||||
<Folder>Functions\Circuits\Providers</Folder>
|
<Folder>Functions\Circuits\Providers</Folder>
|
||||||
<Folder>Functions\Circuits\Types</Folder>
|
<Folder>Functions\Circuits\Types</Folder>
|
||||||
<Folder>Functions\Circuits\Terminations</Folder>
|
<Folder>Functions\Circuits\Terminations</Folder>
|
||||||
<Folder>Functions\Tenancy\Contacts</Folder>
|
|
||||||
<Folder>Functions\Tenancy\Tenants</Folder>
|
|
||||||
<Folder>Functions\Tenancy\ContactRoles</Folder>
|
|
||||||
<Folder>Functions\Tenancy\ContactAssignment</Folder>
|
|
||||||
<Folder>Functions\DCIM\Cable Terminations</Folder>
|
|
||||||
<Folder>Functions\DCIM\Cables</Folder>
|
|
||||||
<Folder>Functions\DCIM\FrontPorts</Folder>
|
|
||||||
<Folder>Functions\DCIM\RearPorts</Folder>
|
|
||||||
<Folder>Functions\Extras</Folder>
|
|
||||||
<Folder>Functions\IPAM\Range</Folder>
|
|
||||||
<Folder>Functions\Extras\Tags</Folder>
|
|
||||||
</Folders>
|
</Folders>
|
||||||
<Files>
|
<Files>
|
||||||
<File Build="2">NetboxPS.psd1</File>
|
<File Build="2">NetboxPS.psd1</File>
|
||||||
|
|
@ -61,6 +48,7 @@
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-BuildURIComponents_ps1" ExportFunctions="True">Functions\Helpers\BuildURIComponents.ps1</File>
|
<File Build="0" Shared="True" ReferenceFunction="Invoke-BuildURIComponents_ps1" ExportFunctions="True">Functions\Helpers\BuildURIComponents.ps1</File>
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-GetNetboxAPIErrorBody_ps1" ExportFunctions="True">Functions\Helpers\GetNetboxAPIErrorBody.ps1</File>
|
<File Build="0" Shared="True" ReferenceFunction="Invoke-GetNetboxAPIErrorBody_ps1" ExportFunctions="True">Functions\Helpers\GetNetboxAPIErrorBody.ps1</File>
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-InvokeNetboxRequest_ps1" ExportFunctions="True">Functions\Helpers\InvokeNetboxRequest.ps1</File>
|
<File Build="0" Shared="True" ReferenceFunction="Invoke-InvokeNetboxRequest_ps1" ExportFunctions="True">Functions\Helpers\InvokeNetboxRequest.ps1</File>
|
||||||
|
<File Build="0" Shared="True" ReferenceFunction="Invoke-ThrowNetboxRESTError_ps1" ExportFunctions="True">Functions\Helpers\ThrowNetboxRESTError.ps1</File>
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-CreateEnum_ps1" ExportFunctions="True">Functions\Helpers\CreateEnum.ps1</File>
|
<File Build="0" Shared="True" ReferenceFunction="Invoke-CreateEnum_ps1" ExportFunctions="True">Functions\Helpers\CreateEnum.ps1</File>
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-VerifyAPIConnectivity_ps1" ExportFunctions="True">Functions\Setup\Support\VerifyAPIConnectivity.ps1</File>
|
<File Build="0" Shared="True" ReferenceFunction="Invoke-VerifyAPIConnectivity_ps1" ExportFunctions="True">Functions\Setup\Support\VerifyAPIConnectivity.ps1</File>
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-SetupNetboxConfigVariable_ps1" ExportFunctions="True">Functions\Setup\Support\SetupNetboxConfigVariable.ps1</File>
|
<File Build="0" Shared="True" ReferenceFunction="Invoke-SetupNetboxConfigVariable_ps1" ExportFunctions="True">Functions\Setup\Support\SetupNetboxConfigVariable.ps1</File>
|
||||||
|
|
@ -81,7 +69,7 @@
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-New-NetboxIPAMPrefix_ps1" ExportFunctions="True">Functions\IPAM\Prefix\New-NetboxIPAMPrefix.ps1</File>
|
<File Build="0" Shared="True" ReferenceFunction="Invoke-New-NetboxIPAMPrefix_ps1" ExportFunctions="True">Functions\IPAM\Prefix\New-NetboxIPAMPrefix.ps1</File>
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Remove-NetboxIPAMAddress_ps1" ExportFunctions="True">Functions\IPAM\Address\Remove-NetboxIPAMAddress.ps1</File>
|
<File Build="0" Shared="True" ReferenceFunction="Invoke-Remove-NetboxIPAMAddress_ps1" ExportFunctions="True">Functions\IPAM\Address\Remove-NetboxIPAMAddress.ps1</File>
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Set-NetboxIPAMAddress_ps1" ExportFunctions="True">Functions\IPAM\Address\Set-NetboxIPAMAddress.ps1</File>
|
<File Build="0" Shared="True" ReferenceFunction="Invoke-Set-NetboxIPAMAddress_ps1" ExportFunctions="True">Functions\IPAM\Address\Set-NetboxIPAMAddress.ps1</File>
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxTenant_ps1" ExportFunctions="True">Functions\Tenancy\Tenants\Get-NetboxTenant.ps1</File>
|
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxTenant_ps1" ExportFunctions="True">Functions\Tenancy\Get-NetboxTenant.ps1</File>
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxVirtualMachine_ps1" ExportFunctions="True">Functions\Virtualization\VirtualMachine\Get-NetboxVirtualMachine.ps1</File>
|
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxVirtualMachine_ps1" ExportFunctions="True">Functions\Virtualization\VirtualMachine\Get-NetboxVirtualMachine.ps1</File>
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-New-NetboxVirtualMachine_ps1" ExportFunctions="True">Functions\Virtualization\VirtualMachine\New-NetboxVirtualMachine.ps1</File>
|
<File Build="0" Shared="True" ReferenceFunction="Invoke-New-NetboxVirtualMachine_ps1" ExportFunctions="True">Functions\Virtualization\VirtualMachine\New-NetboxVirtualMachine.ps1</File>
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Set-NetboxVirtualMachine_ps1" ExportFunctions="True">Functions\Virtualization\VirtualMachine\Set-NetboxVirtualMachine.ps1</File>
|
<File Build="0" Shared="True" ReferenceFunction="Invoke-Set-NetboxVirtualMachine_ps1" ExportFunctions="True">Functions\Virtualization\VirtualMachine\Set-NetboxVirtualMachine.ps1</File>
|
||||||
|
|
@ -127,36 +115,6 @@
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Set-NetboxTimeout_ps1" ExportFunctions="True">Functions\Setup\Set-NetboxTimeout.ps1</File>
|
<File Build="0" Shared="True" ReferenceFunction="Invoke-Set-NetboxTimeout_ps1" ExportFunctions="True">Functions\Setup\Set-NetboxTimeout.ps1</File>
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxTimeout_ps1" ExportFunctions="True">Functions\Setup\Get-NetboxTimeout.ps1</File>
|
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxTimeout_ps1" ExportFunctions="True">Functions\Setup\Get-NetboxTimeout.ps1</File>
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxVersion_ps1" ExportFunctions="True">Functions\Setup\Get-NetboxVersion.ps1</File>
|
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxVersion_ps1" ExportFunctions="True">Functions\Setup\Get-NetboxVersion.ps1</File>
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxContact_ps1" ExportFunctions="True">Functions\Tenancy\Contacts\Get-NetboxContact.ps1</File>
|
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-New-NetboxContact_ps1" ExportFunctions="True">Functions\Tenancy\Contacts\New-NetboxContact.ps1</File>
|
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxContactRole_ps1" ExportFunctions="True">Functions\Tenancy\ContactRoles\Get-NetboxContactRole.ps1</File>
|
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-New-NetboxContactRole_ps1" ExportFunctions="True">Functions\Tenancy\ContactRoles\New-NetboxContactRole.ps1</File>
|
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-New-NetboxTenant_ps1" ExportFunctions="True">Functions\Tenancy\Tenants\New-NetboxTenant.ps1</File>
|
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxContactAssignment_ps1" ExportFunctions="True">Functions\Tenancy\ContactAssignment\Get-NetboxContactAssignment.ps1</File>
|
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxContentType_ps1" ExportFunctions="False">Functions\Setup\Support\Get-NetboxContentType.ps1</File>
|
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-New-NetboxContactAssignment_ps1" ExportFunctions="True">Functions\Tenancy\ContactAssignment\New-NetboxContactAssignment.ps1</File>
|
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Set-NetboxContact_ps1" ExportFunctions="True">Functions\Tenancy\Contacts\Set-NetboxContact.ps1</File>
|
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Test-NetboxAPIConnected_ps1" ExportFunctions="False">Functions\Setup\Support\Test-NetboxAPIConnected.ps1</File>
|
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxDCIMCableTermination_ps1" ExportFunctions="False">Functions\DCIM\Cable Terminations\Get-NetboxDCIMCableTermination.ps1</File>
|
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxDCIMCable_ps1" ExportFunctions="False">Functions\DCIM\Cables\Get-NetboxDCIMCable.ps1</File>
|
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Add-NetboxDCIMFrontPort_ps1" ExportFunctions="False">Functions\DCIM\FrontPorts\Add-NetboxDCIMFrontPort.ps1</File>
|
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxDCIMFrontPort_ps1" ExportFunctions="False">Functions\DCIM\FrontPorts\Get-NetboxDCIMFrontPort.ps1</File>
|
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Remove-NetboxDCIMFrontPort_ps1" ExportFunctions="False">Functions\DCIM\FrontPorts\Remove-NetboxDCIMFrontPort.ps1</File>
|
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Set-NetboxDCIMFrontPort_ps1" ExportFunctions="False">Functions\DCIM\FrontPorts\Set-NetboxDCIMFrontPort.ps1</File>
|
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Add-NetboxDCIMRearPort_ps1" ExportFunctions="False">Functions\DCIM\RearPorts\Add-NetboxDCIMRearPort.ps1</File>
|
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxDCIMRearPort_ps1" ExportFunctions="False">Functions\DCIM\RearPorts\Get-NetboxDCIMRearPort.ps1</File>
|
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Remove-NetboxDCIMRearPort_ps1" ExportFunctions="False">Functions\DCIM\RearPorts\Remove-NetboxDCIMRearPort.ps1</File>
|
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Set-NetboxDCIMRearPort_ps1" ExportFunctions="False">Functions\DCIM\RearPorts\Set-NetboxDCIMRearPort.ps1</File>
|
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-New-NetboxDCIMSite_ps1" ExportFunctions="False">Functions\DCIM\Sites\New-NetboxDCIMSite.ps1</File>
|
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Remove-NetboxDCIMSite_ps1" ExportFunctions="False">Functions\DCIM\Sites\Remove-NetboxDCIMSite.ps1</File>
|
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxTag_ps1" ExportFunctions="True">Functions\Extras\Tags\Get-NetboxTag.ps1</File>
|
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Clear-NetboxCredential_ps1" ExportFunctions="False">Functions\Setup\Clear-NetboxCredential.ps1</File>
|
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxIPAMAddressRange_ps1" ExportFunctions="True">Functions\IPAM\Range\Get-NetboxIPAMAddressRange.ps1</File>
|
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-New-NetboxIPAMAddressRange_ps1" ExportFunctions="True">Functions\IPAM\Range\New-NetboxIPAMAddressRange.ps1</File>
|
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Remove-NetboxIPAMAddressRange_ps1" ExportFunctions="True">Functions\IPAM\Range\Remove-NetboxIPAMAddressRange.ps1</File>
|
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Set-NetboxIPAMAddressRange_ps1" ExportFunctions="True">Functions\IPAM\Range\Set-NetboxIPAMAddressRange.ps1</File>
|
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Set-NetboxContactRole_ps1" ExportFunctions="True">Functions\Tenancy\ContactRoles\Set-NetboxContactRole.ps1</File>
|
|
||||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Set-NetboxContactAssignment_ps1" ExportFunctions="True">Functions\Tenancy\ContactAssignment\Set-NetboxContactAssignment.ps1</File>
|
|
||||||
</Files>
|
</Files>
|
||||||
<StartupScript>R:\Netbox\NetboxPS\Test-Module.ps1</StartupScript>
|
<StartupScript>R:\Netbox\NetboxPS\Test-Module.ps1</StartupScript>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
#
|
#
|
||||||
# Module manifest for module 'NetboxPS'
|
# Module manifest for module 'NetboxPS'
|
||||||
#
|
#
|
||||||
# Generated by: Ben Claussen
|
# Generated by: Ben Claussen
|
||||||
#
|
#
|
||||||
# Generated on: 2023-11-09
|
# Generated on: 2021-07-22
|
||||||
#
|
#
|
||||||
|
|
||||||
@{
|
@{
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
RootModule = 'NetboxPS.psm1'
|
RootModule = 'NetboxPS.psm1'
|
||||||
|
|
||||||
# Version number of this module.
|
# Version number of this module.
|
||||||
ModuleVersion = '1.8.5'
|
ModuleVersion = '1.4'
|
||||||
|
|
||||||
# Supported PSEditions
|
# Supported PSEditions
|
||||||
# CompatiblePSEditions = @()
|
# CompatiblePSEditions = @()
|
||||||
|
|
@ -54,7 +54,7 @@ CLRVersion = '2.0.50727'
|
||||||
# RequiredModules = @()
|
# RequiredModules = @()
|
||||||
|
|
||||||
# Assemblies that must be loaded prior to importing this module
|
# Assemblies that must be loaded prior to importing this module
|
||||||
# RequiredAssemblies = @()
|
RequiredAssemblies = 'System.Web'
|
||||||
|
|
||||||
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
|
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
|
||||||
# ScriptsToProcess = @()
|
# ScriptsToProcess = @()
|
||||||
|
|
@ -69,49 +69,7 @@ CLRVersion = '2.0.50727'
|
||||||
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.
|
# 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',
|
FunctionsToExport = '*'
|
||||||
'Add-NetboxDCIMInterfaceConnection', 'Add-NetboxDCIMRearPort',
|
|
||||||
'Add-NetboxVirtualMachineInterface', 'Clear-NetboxCredential',
|
|
||||||
'Connect-NetboxAPI', 'Get-ModelDefinition', 'Get-NetboxAPIDefinition',
|
|
||||||
'Get-NetboxCircuit', 'Get-NetboxCircuitProvider',
|
|
||||||
'Get-NetboxCircuitTermination', 'Get-NetboxCircuitType',
|
|
||||||
'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-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',
|
|
||||||
'Remove-NetboxDCIMInterfaceConnection', 'Remove-NetboxDCIMRearPort',
|
|
||||||
'Remove-NetboxDCIMSite', 'Remove-NetboxIPAMAddress',
|
|
||||||
'Remove-NetboxIPAMAddressRange', 'Remove-NetboxVirtualMachine',
|
|
||||||
'Set-NetboxCipherSSL', 'Set-NetboxContact',
|
|
||||||
'Set-NetboxContactAssignment', 'Set-NetboxContactRole',
|
|
||||||
'Set-NetboxCredential', 'Set-NetboxDCIMDevice',
|
|
||||||
'Set-NetboxDCIMFrontPort', 'Set-NetboxDCIMInterface',
|
|
||||||
'Set-NetboxDCIMInterfaceConnection', 'Set-NetboxDCIMRearPort',
|
|
||||||
'Set-NetboxHostName', 'Set-NetboxHostPort', 'Set-NetboxHostScheme',
|
|
||||||
'Set-NetboxInvokeParams', 'Set-NetboxIPAMAddress',
|
|
||||||
'Set-NetboxIPAMAddressRange', 'Set-NetboxIPAMPrefix',
|
|
||||||
'Set-NetboxTimeout', 'Set-NetboxUnstrustedSSL',
|
|
||||||
'Set-NetboxVirtualMachine', 'Set-NetboxVirtualMachineInterface',
|
|
||||||
'Test-NetboxAPIConnected'
|
|
||||||
|
|
||||||
# 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.
|
# 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 = '*'
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
61
README.md
61
README.md
|
|
@ -4,69 +4,10 @@
|
||||||
# Disclaimer
|
# 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.
|
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
|
# Description
|
||||||
This module is a wrapper for the [Netbox](https://github.com/netbox-community/netbox) API.
|
This module is a wrapper for the [Netbox](https://github.com/netbox-community/netbox) API.
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
1. Install module from the `netboxPS` folder
|
1. Install module from the `netboxPS` folder
|
||||||
2. Import module
|
2. Import module
|
||||||
3. Connect to an API endpoint by using `Connect-NetboxAPI -Hostname netbox.example.com`
|
3. Connect to an API endpoint by using `Connect-NetboxAPI -Hostname netbox.example.com`
|
||||||
|
|
||||||
## Basic Commands
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
#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
|
|
||||||
- Follow [Powershell Practice and Style Guidelines](https://poshcode.gitbook.io/powershell-practice-and-style/) when writing code
|
|
||||||
- Use discussions for general questions
|
|
||||||
- Open issues for bug fixes or enhancements
|
|
||||||
- Submit all pull requests against the dev branch
|
|
||||||
|
|
||||||
I am always open to suggestions for improvement with reasons and data to back up the suggestion.
|
|
||||||
1
Tests/.gitignore
vendored
1
Tests/.gitignore
vendored
|
|
@ -1 +0,0 @@
|
||||||
credential.ps1
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue