NetboxPS/dist/NetboxPS.psm1

3629 lines
99 KiB
PowerShell
Raw Normal View History

2018-05-11 15:54:43 -04:00
<#
.NOTES
--------------------------------------------------------------------------------
2020-03-23 12:18:01 -04:00
Code generated by: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
Generated on: 3/23/2020 12:17
Generated by: Claussen
2018-05-11 15:54:43 -04:00
Organization: NEOnet
--------------------------------------------------------------------------------
.DESCRIPTION
2020-03-23 12:18:01 -04:00
Script generated by PowerShell Studio 2020
2018-05-11 15:54:43 -04:00
#>
#region Invoke-Helpers_ps1
<#
2018-05-11 16:33:26 -04:00
.NOTES
===========================================================================
2018-05-11 15:54:43 -04:00
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2018 v5.5.148
2018-05-11 16:33:26 -04:00
Created on: 2/28/2018 3:33 PM
Created by: Ben Claussen
Organization: NEOnet
Filename: Helpers.ps1
===========================================================================
.DESCRIPTION
These function are internal functions and generally are not
2018-05-11 15:54:43 -04:00
exposed to the end user
#>
function CheckNetboxIsConnected {
[CmdletBinding()]
param ()
Write-Verbose "Checking connection status"
if (-not $script:NetboxConfig.Connected) {
throw "Not connected to a Netbox API! Please run 'Connect-NetboxAPI'"
}
}
function BuildNewURI {
<#
.SYNOPSIS
Create a new URI for Netbox
.DESCRIPTION
2018-05-29 10:43:23 -04:00
Internal function used to build a URIBuilder object.
2018-05-11 15:54:43 -04:00
.PARAMETER Hostname
Hostname of the Netbox API
.PARAMETER Segments
Array of strings for each segment in the URL path
.PARAMETER Parameters
Hashtable of query parameters to include
.PARAMETER HTTPS
Whether to use HTTPS or HTTP
.PARAMETER Port
A description of the Port parameter.
.PARAMETER APIInfo
A description of the APIInfo parameter.
.EXAMPLE
PS C:\> BuildNewURI
.NOTES
Additional information about the function.
#>
[CmdletBinding()]
[OutputType([System.UriBuilder])]
param
(
[Parameter(Mandatory = $false)]
[string]$Hostname,
[Parameter(Mandatory = $false)]
[string[]]$Segments,
[Parameter(Mandatory = $false)]
[hashtable]$Parameters,
[Parameter(Mandatory = $false)]
[boolean]$HTTPS = $true,
[ValidateRange(1, 65535)]
[uint16]$Port = 443,
[switch]$SkipConnectedCheck
)
Write-Verbose "Building URI"
if (-not $SkipConnectedCheck) {
# There is no point in continuing if we have not successfully connected to an API
$null = CheckNetboxIsConnected
}
if (-not $Hostname) {
$Hostname = Get-NetboxHostname
}
if ($HTTPS) {
2018-05-14 16:46:12 -04:00
Write-Verbose " Setting scheme to HTTPS"
2018-05-11 15:54:43 -04:00
$Scheme = 'https'
} else {
2018-05-14 16:46:12 -04:00
Write-Warning " Connecting via non-secure HTTP is not-recommended"
2018-05-11 15:54:43 -04:00
2018-05-14 16:46:12 -04:00
Write-Verbose " Setting scheme to HTTP"
2018-05-11 15:54:43 -04:00
$Scheme = 'http'
if (-not $PSBoundParameters.ContainsKey('Port')) {
# Set the port to 80 if the user did not supply it
2018-05-14 16:46:12 -04:00
Write-Verbose " Setting port to 80 as default because it was not supplied by the user"
2018-05-11 15:54:43 -04:00
$Port = 80
}
}
# Begin a URI builder with HTTP/HTTPS and the provided hostname
$uriBuilder = [System.UriBuilder]::new($Scheme, $Hostname, $Port)
# Generate the path by trimming excess slashes and whitespace from the $segments[] and joining together
$uriBuilder.Path = "api/{0}/" -f ($Segments.ForEach({$_.trim('/').trim()}) -join '/')
2018-05-14 16:46:12 -04:00
Write-Verbose " URIPath: $($uriBuilder.Path)"
2018-05-11 15:54:43 -04:00
if ($parameters) {
# Loop through the parameters and use the HttpUtility to create a Query string
[System.Collections.Specialized.NameValueCollection]$URIParams = [System.Web.HttpUtility]::ParseQueryString([String]::Empty)
foreach ($param in $Parameters.GetEnumerator()) {
2018-05-14 16:46:12 -04:00
Write-Verbose " Adding URI parameter $($param.Key):$($param.Value)"
2018-05-11 15:54:43 -04:00
$URIParams[$param.Key] = $param.Value
}
$uriBuilder.Query = $URIParams.ToString()
}
2018-05-14 16:46:12 -04:00
Write-Verbose " Completed building URIBuilder"
2018-05-11 15:54:43 -04:00
# Return the entire UriBuilder object
$uriBuilder
}
2018-05-14 16:46:12 -04:00
function BuildURIComponents {
[CmdletBinding()]
[OutputType([hashtable])]
param
(
[Parameter(Mandatory = $true)]
[System.Collections.ArrayList]$URISegments,
[Parameter(Mandatory = $true)]
[object]$ParametersDictionary,
[string[]]$SkipParameterByName
)
Write-Verbose "Building URI components"
2018-05-18 12:14:27 -04:00
$URIParameters = @{}
2018-05-14 16:46:12 -04:00
foreach ($CmdletParameterName in $ParametersDictionary.Keys) {
2018-05-29 10:43:23 -04:00
if ($CmdletParameterName -in $script:CommonParameterNames) {
2018-05-14 16:46:12 -04:00
# These are common parameters and should not be appended to the URI
2018-05-29 10:43:23 -04:00
Write-Debug "Skipping common parameter $CmdletParameterName"
2018-05-14 16:46:12 -04:00
continue
}
if ($CmdletParameterName -in $SkipParameterByName) {
2018-05-29 10:43:23 -04:00
Write-Debug "Skipping parameter $CmdletParameterName by SkipParameterByName"
2018-05-14 16:46:12 -04:00
continue
}
2019-12-10 15:09:42 -05:00
switch ($CmdletParameterName) {
"id" {
# Check if there is one or more values for Id and build a URI or query as appropriate
if (@($ParametersDictionary[$CmdletParameterName]).Count -gt 1) {
Write-Verbose " Joining IDs for parameter"
$URIParameters['id__in'] = $ParametersDictionary[$CmdletParameterName] -join ','
} else {
Write-Verbose " Adding ID to segments"
[void]$uriSegments.Add($ParametersDictionary[$CmdletParameterName])
}
break
}
'Query' {
Write-Verbose " Adding query parameter"
$URIParameters['q'] = $ParametersDictionary[$CmdletParameterName]
break
}
'CustomFields' {
Write-Verbose " Adding custom field query parameters"
foreach ($field in $ParametersDictionary[$CmdletParameterName].GetEnumerator()) {
Write-Verbose " Adding parameter 'cf_$($field.Key) = $($field.Value)"
$URIParameters["cf_$($field.Key.ToLower())"] = $field.Value
}
break
}
default {
Write-Verbose " Adding $($CmdletParameterName.ToLower()) parameter"
$URIParameters[$CmdletParameterName.ToLower()] = $ParametersDictionary[$CmdletParameterName]
break
2018-05-14 16:46:12 -04:00
}
}
}
return @{
'Segments' = [System.Collections.ArrayList]$URISegments
'Parameters' = $URIParameters
}
}
function GetChoiceValidValues {
[CmdletBinding()]
2018-05-18 12:14:27 -04:00
[OutputType([System.Collections.ArrayList])]
2018-05-14 16:46:12 -04:00
param
(
[Parameter(Mandatory = $true)]
[string]$MajorObject,
[Parameter(Mandatory = $true)]
[object]$Choice
)
$ValidValues = New-Object System.Collections.ArrayList
if (-not $script:NetboxConfig.Choices.$MajorObject.$Choice) {
throw "Missing choices for $Choice"
}
[void]$ValidValues.AddRange($script:NetboxConfig.Choices.$MajorObject.$Choice.value)
[void]$ValidValues.AddRange($script:NetboxConfig.Choices.$MajorObject.$Choice.label)
if ($ValidValues.Count -eq 0) {
throw "Missing valid values for $MajorObject.$Choice"
}
return [System.Collections.ArrayList]$ValidValues
}
function ValidateChoice {
[CmdletBinding()]
2020-03-23 12:18:01 -04:00
[OutputType([uint16], [string], [bool])]
2018-05-14 16:46:12 -04:00
param
(
[Parameter(Mandatory = $true)]
2018-05-29 10:43:23 -04:00
[ValidateSet('Circuits', 'DCIM', 'Extras', 'IPAM', 'Virtualization', IgnoreCase = $true)]
2018-05-14 16:46:12 -04:00
[string]$MajorObject,
[Parameter(Mandatory = $true)]
2018-05-18 12:14:27 -04:00
[string]$ChoiceName,
[Parameter(Mandatory = $true)]
[object]$ProvidedValue
2018-05-14 16:46:12 -04:00
)
$ValidValues = GetChoiceValidValues -MajorObject $MajorObject -Choice $ChoiceName
Write-Verbose "Validating $ChoiceName"
2018-05-18 12:14:27 -04:00
Write-Verbose "Checking '$ProvidedValue' against [$($ValidValues -join ', ')]"
2018-05-29 10:43:23 -04:00
# Coercing everything to strings for matching...
# some values are integers, some are strings, some are booleans
# Join the valid values with a pipe as a delimeter, because some values have spaces
if (([string]($ValidValues -join '|') -split '\|') -inotcontains [string]$ProvidedValue) {
2018-05-14 16:46:12 -04:00
throw "Invalid value '$ProvidedValue' for '$ChoiceName'. Must be one of: $($ValidValues -join ', ')"
}
2018-05-29 10:43:23 -04:00
switch -wildcard ("$MajorObject/$ChoiceName") {
"Circuits" {
# This has things that are not integers
}
"DCIM/*connection_status" {
# This has true/false values instead of integers
try {
$val = [bool]::Parse($ProvidedValue)
} catch {
# It must not be a true/false value
$val = $script:NetboxConfig.Choices.$MajorObject.$ChoiceName.Where({ $_.Label -eq $ProvidedValue }).Value
}
return $val
}
default {
# Convert the ProvidedValue to the integer value
try {
$intVal = [uint16]"$ProvidedValue"
} catch {
# It must not be a number, get the value from the label
$intVal = [uint16]$script:NetboxConfig.Choices.$MajorObject.$ChoiceName.Where({ $_.Label -eq $ProvidedValue }).Value
}
return $intVal
}
2018-05-14 16:46:12 -04:00
}
}
2018-05-11 15:54:43 -04:00
function GetNetboxAPIErrorBody {
param
(
[Parameter(Mandatory = $true)]
[System.Net.HttpWebResponse]$Response
)
# 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
$reader = New-Object System.IO.StreamReader($Response.GetResponseStream())
$reader.BaseStream.Position = 0
$reader.DiscardBufferedData()
$reader.ReadToEnd()
}
function InvokeNetboxRequest {
2018-05-18 12:14:27 -04:00
[CmdletBinding()]
2018-05-11 15:54:43 -04:00
param
(
[Parameter(Mandatory = $true)]
[System.UriBuilder]$URI,
[Hashtable]$Headers = @{},
[pscustomobject]$Body = $null,
[ValidateRange(0, 60)]
[uint16]$Timeout = 5,
[ValidateSet('GET', 'PATCH', 'PUT', 'POST', 'DELETE', IgnoreCase = $true)]
[string]$Method = 'GET',
[switch]$Raw
)
2018-05-21 15:36:04 -04:00
$creds = Get-NetboxCredential
2018-05-11 15:54:43 -04:00
$Headers.Authorization = "Token {0}" -f $creds.GetNetworkCredential().Password
$splat = @{
'Method' = $Method
'Uri' = $URI.Uri.AbsoluteUri # This property auto generates the scheme, hostname, path, and query
'Headers' = $Headers
'TimeoutSec' = $Timeout
'ContentType' = 'application/json'
'ErrorAction' = 'Stop'
'Verbose' = $VerbosePreference
}
if ($Body) {
Write-Verbose "BODY: $($Body | ConvertTo-Json -Compress)"
$null = $splat.Add('Body', ($Body | ConvertTo-Json -Compress))
}
$result = Invoke-RestMethod @splat
#region TODO: Handle errors a little more gracefully...
<#
try {
Write-Verbose "Sending request..."
$result = Invoke-RestMethod @splat
Write-Verbose $result
} catch {
Write-Verbose "Caught exception"
if ($_.Exception.psobject.properties.Name.contains('Response')) {
Write-Verbose "Exception contains a response property"
if ($Raw) {
Write-Verbose "RAW provided...throwing raw exception"
throw $_
}
Write-Verbose "Converting response to object"
$myError = GetNetboxAPIErrorBody -Response $_.Exception.Response | ConvertFrom-Json
} else {
Write-Verbose "No response property found"
$myError = $_
}
}
Write-Verbose "MyError is $($myError.GetType().FullName)"
if ($myError -is [Exception]) {
throw $_
} elseif ($myError -is [pscustomobject]) {
throw $myError.detail
}
#>
#endregion TODO: Handle errors a little more gracefully...
# If the user wants the raw value from the API... otherwise return only the actual result
if ($Raw) {
2018-05-16 10:54:20 -04:00
Write-Verbose "Returning raw result by choice"
2018-05-11 15:54:43 -04:00
return $result
} else {
if ($result.psobject.Properties.Name.Contains('results')) {
Write-Verbose "Found Results property on data, returning results directly"
return $result.Results
} else {
Write-Verbose "Did NOT find results property on data, returning raw result"
return $result
}
2018-05-14 16:46:12 -04:00
}
2018-05-11 15:54:43 -04:00
}
2018-05-14 16:46:12 -04:00
#region Troubleshooting commands
2018-05-11 15:54:43 -04:00
function ThrowNetboxRESTError {
$uriSegments = [System.Collections.ArrayList]::new(@('fake', 'url'))
$URIParameters = @{}
$uri = BuildNewURI -Segments $uriSegments -Parameters $URIParameters
InvokeNetboxRequest -URI $uri -Raw
}
2018-05-14 16:46:12 -04:00
function CreateEnum {
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true)]
[string]$EnumName,
[Parameter(Mandatory = $true)]
[pscustomobject]$Values,
[switch]$PassThru
)
$definition = @"
public enum $EnumName
{`n$(foreach ($value in $values) {"`t$($value.label) = $($value.value),`n"})
}
"@
if (-not ([System.Management.Automation.PSTypeName]"$EnumName").Type) {
#Write-Host $definition -ForegroundColor Green
Add-Type -TypeDefinition $definition -PassThru:$PassThru
} else {
Write-Warning "EnumType $EnumName already exists."
}
}
2018-05-11 15:54:43 -04:00
2018-05-14 16:46:12 -04:00
#endregion Troubleshooting commands
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
#endregion
2018-05-11 15:54:43 -04:00
#region Invoke-Setup_ps1
<#
.NOTES
===========================================================================
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2018 v5.5.148
Created on: 2/28/2018 3:33 PM
Created by: Ben Claussen
Organization: NEOnet
Filename: Setup.ps1
===========================================================================
.DESCRIPTION
These are the function used to setup the environment for connecting
to a Netbox API
#>
function Set-NetboxHostName {
2018-05-21 15:36:04 -04:00
[CmdletBinding(ConfirmImpact = 'Low',
2018-05-18 12:14:27 -04:00
SupportsShouldProcess = $true)]
[OutputType([string])]
param
(
[Parameter(Mandatory = $true)]
[string]$Hostname
)
2018-05-21 15:36:04 -04:00
if ($PSCmdlet.ShouldProcess('Netbox Hostname', 'Set')) {
$script:NetboxConfig.Hostname = $Hostname.Trim()
$script:NetboxConfig.Hostname
}
2018-05-11 15:54:43 -04:00
}
function Get-NetboxHostname {
[CmdletBinding()]
param ()
Write-Verbose "Getting Netbox hostname"
2018-05-18 12:14:27 -04:00
if ($null -eq $script:NetboxConfig.Hostname) {
2018-05-11 15:54:43 -04:00
throw "Netbox Hostname is not set! You may set it with Set-NetboxHostname -Hostname 'hostname.domain.tld'"
}
$script:NetboxConfig.Hostname
}
2018-05-21 15:36:04 -04:00
function Set-NetboxCredential {
2018-05-18 12:14:27 -04:00
[CmdletBinding(DefaultParameterSetName = 'CredsObject',
2018-05-21 15:36:04 -04:00
ConfirmImpact = 'Low',
2018-05-18 12:14:27 -04:00
SupportsShouldProcess = $true)]
[OutputType([pscredential])]
param
(
[Parameter(ParameterSetName = 'CredsObject',
Mandatory = $true)]
2018-05-21 15:36:04 -04:00
[pscredential]$Credential,
2018-05-18 12:14:27 -04:00
[Parameter(ParameterSetName = 'UserPass',
Mandatory = $true)]
2018-05-21 15:36:04 -04:00
[securestring]$Token
2018-05-18 12:14:27 -04:00
)
2018-05-21 15:36:04 -04:00
if ($PSCmdlet.ShouldProcess('Netbox Credentials', 'Set')) {
switch ($PsCmdlet.ParameterSetName) {
'CredsObject' {
$script:NetboxConfig.Credential = $Credential
break
}
'UserPass' {
$script:NetboxConfig.Credential = [System.Management.Automation.PSCredential]::new('notapplicable', $Token)
break
}
2018-05-18 12:14:27 -04:00
}
2018-05-21 15:36:04 -04:00
$script:NetboxConfig.Credential
2018-05-18 12:14:27 -04:00
}
2018-05-11 15:54:43 -04:00
}
2018-05-21 15:36:04 -04:00
function Get-NetboxCredential {
2018-05-11 15:54:43 -04:00
[CmdletBinding()]
[OutputType([pscredential])]
param ()
2018-05-21 15:36:04 -04:00
if (-not $script:NetboxConfig.Credential) {
throw "Netbox Credentials not set! You may set with Set-NetboxCredential"
2018-05-11 15:54:43 -04:00
}
2018-05-21 15:36:04 -04:00
$script:NetboxConfig.Credential
2018-05-11 15:54:43 -04:00
}
function Connect-NetboxAPI {
<#
.SYNOPSIS
2018-05-21 15:36:04 -04:00
Connects to the Netbox API and ensures Credential work properly
2018-05-11 15:54:43 -04:00
.DESCRIPTION
A detailed description of the Connect-NetboxAPI function.
.PARAMETER Hostname
A description of the Hostname parameter.
2018-05-21 15:36:04 -04:00
.PARAMETER Credential
A description of the Credential parameter.
2018-05-11 15:54:43 -04:00
.EXAMPLE
PS C:\> Connect-NetboxAPI -Hostname "netbox.domain.com"
2018-05-21 15:36:04 -04:00
This will prompt for Credential, then proceed to attempt a connection to Netbox
2018-05-11 15:54:43 -04:00
.NOTES
Additional information about the function.
#>
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true)]
[string]$Hostname,
[Parameter(Mandatory = $false)]
2018-05-21 15:36:04 -04:00
[pscredential]$Credential
2018-05-11 15:54:43 -04:00
)
2018-05-21 15:36:04 -04:00
if (-not $Credential) {
2018-05-11 15:54:43 -04:00
try {
2018-05-21 15:36:04 -04:00
$Credential = Get-NetboxCredential -ErrorAction Stop
2018-05-11 15:54:43 -04:00
} catch {
# Credentials are not set... Try to obtain from the user
2018-05-21 15:36:04 -04:00
if (-not ($Credential = Get-Credential -UserName 'username-not-applicable' -Message "Enter token for Netbox")) {
2018-05-11 15:54:43 -04:00
throw "Token is necessary to connect to a Netbox API."
}
}
}
$null = Set-NetboxHostName -Hostname $Hostname
2018-05-21 15:36:04 -04:00
$null = Set-NetboxCredential -Credential $Credential
2018-05-11 15:54:43 -04:00
try {
Write-Verbose "Verifying API connectivity..."
2018-05-18 12:14:27 -04:00
$null = VerifyAPIConnectivity
2018-05-11 15:54:43 -04:00
$script:NetboxConfig.Connected = $true
Write-Verbose "Successfully connected!"
} catch {
Write-Verbose "Failed to connect. Generating error"
Write-Verbose $_.Exception.Message
if (($_.Exception.Response) -and ($_.Exception.Response.StatusCode -eq 403)) {
throw "Invalid token"
} else {
throw $_
}
}
2018-05-14 16:46:12 -04:00
Write-Verbose "Caching static choices"
2018-05-11 15:54:43 -04:00
$script:NetboxConfig.Choices.Circuits = Get-NetboxCircuitsChoices
2018-05-29 10:43:23 -04:00
$script:NetboxConfig.Choices.DCIM = Get-NetboxDCIMChoices # Not completed yet
2018-05-11 15:54:43 -04:00
$script:NetboxConfig.Choices.Extras = Get-NetboxExtrasChoices
$script:NetboxConfig.Choices.IPAM = Get-NetboxIPAMChoices
2018-05-14 16:46:12 -04:00
#$script:NetboxConfig.Choices.Secrets = Get-NetboxSecretsChoices # Not completed yet
2019-12-10 15:09:42 -05:00
#$script:NetboxConfig.Choices.Tenancy = Get-NetboxTenancyChoices
2018-05-11 15:54:43 -04:00
$script:NetboxConfig.Choices.Virtualization = Get-NetboxVirtualizationChoices
2018-05-14 16:46:12 -04:00
Write-Verbose "Connection process completed"
2018-05-11 15:54:43 -04:00
}
2020-03-23 12:18:01 -04:00
#endregion
2018-05-11 15:54:43 -04:00
#region Invoke-Extras_ps1
<#
.NOTES
===========================================================================
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2018 v5.5.148
Created on: 2/28/2018 3:43 PM
Created by: Ben Claussen
Organization: NEOnet
Filename: Extras.ps1
===========================================================================
.DESCRIPTION
Extras objects functions
#>
function Get-NetboxExtrasChoices {
2018-05-18 12:14:27 -04:00
[CmdletBinding()]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Justification = "These are literally 'choices' in Netbox")]
2018-05-11 15:54:43 -04:00
param ()
$uriSegments = [System.Collections.ArrayList]::new(@('extras', '_choices'))
$uri = BuildNewURI -Segments $uriSegments
InvokeNetboxRequest -URI $uri
}
2020-03-23 12:18:01 -04:00
#endregion
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
#region Invoke-ValidateDCIMChoice_ps1
function ValidateDCIMChoice {
2018-05-11 15:54:43 -04:00
<#
.SYNOPSIS
2020-03-23 12:18:01 -04:00
Internal function to validate provided values for static choices
2018-05-11 15:54:43 -04:00
.DESCRIPTION
2020-03-23 12:18:01 -04:00
When users connect to the API, choices for each major object are cached to the config variable.
These values are then utilized to validate if the provided value from a user is valid.
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER ProvidedValue
The value to validate against static choices
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER PowerConnectionStatus
Validate against power connection status values
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER InterfaceTemplateFormFactor
Validate against interface template form factor values
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER InterfaceConnectionStatus
Validate against interface connection status values
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER InterfaceFormFactor
Validate against interface form factor values
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER ConsolePortConnectionStatus
Validate against console port connection status values
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER DeviceStatus
Validate against device status values
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER DeviceFace
Validate against device face values
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER RackType
Validate against rack type values
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER RackWidth
Validate against rack width values.
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
.EXAMPLE
PS C:\> ValidateDCIMChoice -ProvidedValue 'rear' -DeviceFace
2018-05-11 15:54:43 -04:00
.EXAMPLE
2020-03-23 12:18:01 -04:00
PS C:\> ValidateDCIMChoice -ProvidedValue 'middle' -DeviceFace
>> Invalid value middle for device:face. Must be one of: 0, 1, Front, Rear
.OUTPUTS
This function returns the integer value if valid. Otherwise, it will throw an error.
2018-05-11 15:54:43 -04:00
.NOTES
Additional information about the function.
2020-03-23 12:18:01 -04:00
.FUNCTIONALITY
This cmdlet is intended to be used internally and not exposed to the user
2018-05-11 15:54:43 -04:00
#>
[CmdletBinding()]
2020-03-23 12:18:01 -04:00
[OutputType([uint16])]
2018-05-11 15:54:43 -04:00
param
(
2020-03-23 12:18:01 -04:00
[Parameter(Mandatory = $true)]
[object]$ProvidedValue,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[Parameter(ParameterSetName = 'power-port:connection_status',
Mandatory = $true)]
[switch]$PowerConnectionStatus,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[Parameter(ParameterSetName = 'interface-template:form_factor',
Mandatory = $true)]
[switch]$InterfaceTemplateFormFactor,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[Parameter(ParameterSetName = 'interface-connection:connection_status',
Mandatory = $true)]
[switch]$InterfaceConnectionStatus,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[Parameter(ParameterSetName = 'interface:form_factor',
Mandatory = $true)]
[switch]$InterfaceFormFactor,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[Parameter(ParameterSetName = 'console-port:connection_status',
Mandatory = $true)]
[switch]$ConsolePortConnectionStatus,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[Parameter(ParameterSetName = 'device:status',
Mandatory = $true)]
[switch]$DeviceStatus,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[Parameter(ParameterSetName = 'device:face',
Mandatory = $true)]
[switch]$DeviceFace,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[Parameter(ParameterSetName = 'rack:type',
Mandatory = $true)]
[switch]$RackType,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[Parameter(ParameterSetName = 'rack:width',
Mandatory = $true)]
[switch]$RackWidth
)
ValidateChoice -MajorObject 'DCIM' -ChoiceName $PSCmdlet.ParameterSetName -ProvidedValue $ProvidedValue
}
#endregion
#region Invoke-Setup_Support_ps1
function VerifyAPIConnectivity {
[CmdletBinding()]
param ()
$uriSegments = [System.Collections.ArrayList]::new(@('extras', '_choices'))
$uri = BuildNewURI -Segments $uriSegments -SkipConnectedCheck
InvokeNetboxRequest -URI $uri
}
function SetupNetboxConfigVariable {
[CmdletBinding()]
param
(
[switch]$Overwrite
)
Write-Verbose "Checking for NetboxConfig hashtable"
if ((-not ($script:NetboxConfig)) -or $Overwrite) {
Write-Verbose "Creating NetboxConfig hashtable"
$script:NetboxConfig = @{
'Connected' = $false
'Choices' = @{
}
}
}
Write-Verbose "NetboxConfig hashtable already exists"
}
function GetNetboxConfigVariable {
return $script:NetboxConfig
}
#endregion
#region Invoke-Get-NetboxIPAMVLAN_ps1
<#
.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 {
[CmdletBinding()]
param
(
[uint16]$Limit,
[uint16]$Offset,
[uint16]$VID,
[uint16[]]$Id,
[string]$Query,
[string]$Name,
[string]$Tenant,
[uint16]$Tenant_Id,
[string]$TenantGroup,
[uint16]$TenantGroup_Id,
[object]$Status,
[string]$Region,
[string]$Site,
[uint16]$Site_Id,
[string]$Group,
[uint16]$Group_Id,
[string]$Role,
[uint16]$Role_Id,
2018-05-11 15:54:43 -04:00
[switch]$Raw
)
2018-05-18 12:14:27 -04:00
if ($null -ne $Status) {
2020-03-23 12:18:01 -04:00
$PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -VLANStatus
2018-05-14 16:46:12 -04:00
}
2020-03-23 12:18:01 -04:00
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'vlans'))
2018-05-11 15:54:43 -04:00
2018-05-16 10:54:20 -04:00
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
2018-05-11 15:54:43 -04:00
2018-05-14 16:46:12 -04:00
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
2018-05-11 15:54:43 -04:00
InvokeNetboxRequest -URI $uri -Raw:$Raw
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-New-NetboxIPAMVLAN_ps1
function New-NetboxIPAMAddress {
2018-05-11 15:54:43 -04:00
<#
.SYNOPSIS
2020-03-23 12:18:01 -04:00
Create a new IP address to Netbox
2018-05-11 15:54:43 -04:00
.DESCRIPTION
2020-03-23 12:18:01 -04:00
Create a new IP address to Netbox with a status of Active by default.
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER Address
IP address in CIDR notation: 192.168.1.1/24
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER Status
Status of the IP. Defaults to Active
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER Tenant
Tenant ID
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER VRF
VRF ID
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER Role
Role such as anycast, loopback, etc... Defaults to nothing
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER NAT_Inside
ID of IP for NAT
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER Custom_Fields
Custom field hash table. Will be validated by the API service
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER Interface
ID of interface to apply IP
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER Description
Description of IP address
2018-05-11 15:54:43 -04:00
.PARAMETER Raw
2020-03-23 12:18:01 -04:00
Return raw results from API service
2018-05-11 15:54:43 -04:00
.EXAMPLE
2020-03-23 12:18:01 -04:00
PS C:\> Create-NetboxIPAMAddress
2018-05-11 15:54:43 -04:00
.NOTES
Additional information about the function.
#>
[CmdletBinding()]
2020-03-23 12:18:01 -04:00
[OutputType([pscustomobject])]
2018-05-11 15:54:43 -04:00
param
(
2020-03-23 12:18:01 -04:00
[Parameter(Mandatory = $true)]
[uint16]$VID,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[object]$Status = 'Active',
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$Tenant,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$VRF,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[object]$Role,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$NAT_Inside,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[hashtable]$Custom_Fields,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$Interface,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[string]$Description,
2018-05-11 15:54:43 -04:00
[switch]$Raw
)
2020-03-23 12:18:01 -04:00
$PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -VLANStatus
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
if ($null -ne $Role) {
$PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -IPAddressRole
}
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
$segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
$URIComponents = BuildURIComponents -URISegments $segments -ParametersDictionary $PSBoundParameters
$URI = BuildNewURI -Segments $URIComponents.Segments
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters -Raw:$Raw
2018-05-11 15:54:43 -04:00
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-Get-NetboxIPAMRole_ps1
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
function Get-NetboxIPAMRole {
2018-05-11 15:54:43 -04:00
<#
.SYNOPSIS
2020-03-23 12:18:01 -04:00
Get IPAM Prefix/VLAN roles
2018-05-11 15:54:43 -04:00
.DESCRIPTION
2020-03-23 12:18:01 -04:00
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).
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER Id
Unique ID
2018-05-11 15:54:43 -04:00
.PARAMETER Query
2020-03-23 12:18:01 -04:00
Search query
2018-05-11 15:54:43 -04:00
.PARAMETER Name
2020-03-23 12:18:01 -04:00
Role name
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER Slug
Role URL slug
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER Brief
Brief format
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER Limit
Result limit
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER Offset
Result offset
2018-05-11 15:54:43 -04:00
.PARAMETER Raw
A description of the Raw parameter.
.EXAMPLE
2020-03-23 12:18:01 -04:00
PS C:\> Get-NetboxIPAMRole
2018-05-11 15:54:43 -04:00
.NOTES
Additional information about the function.
#>
[CmdletBinding()]
param
(
2020-03-23 12:18:01 -04:00
[uint16[]]$Id,
2018-05-11 15:54:43 -04:00
[string]$Query,
[string]$Name,
2020-03-23 12:18:01 -04:00
[string]$Slug,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[switch]$Brief,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$Limit,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$Offset,
2018-05-11 15:54:43 -04:00
[switch]$Raw
)
2020-03-23 12:18:01 -04:00
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'roles'))
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
2018-05-11 15:54:43 -04:00
InvokeNetboxRequest -URI $uri -Raw:$Raw
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-Get-NetboxIPAMAggregate_ps1
<#
.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 {
[CmdletBinding()]
param
(
2018-05-11 15:54:43 -04:00
[uint16]$Limit,
[uint16]$Offset,
2020-03-23 12:18:01 -04:00
[object]$Family,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[datetime]$Date_Added,
[uint16[]]$Id,
[string]$Query,
[uint16]$RIR_Id,
[string]$RIR,
2018-05-11 15:54:43 -04:00
[switch]$Raw
)
2020-03-23 12:18:01 -04:00
if ($null -ne $Family) {
$PSBoundParameters.Family = ValidateIPAMChoice -ProvidedValue $Family -AggregateFamily
}
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'aggregates'))
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
2018-05-11 15:54:43 -04:00
InvokeNetboxRequest -URI $uri -Raw:$Raw
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-Get-NetboxIPAMAddress_ps1
function Get-NetboxIPAMAddress {
2018-05-11 15:54:43 -04:00
[CmdletBinding()]
param
(
2020-03-23 12:18:01 -04:00
[uint16]$Limit,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$Offset,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[object]$Family,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[uint16[]]$Id,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[string]$Query,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$Parent,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[byte]$Mask_Length,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[string]$VRF,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$VRF_Id,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[string]$Tenant,
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
[uint16]$Tenant_Id,
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
[string]$Device,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$Device_ID,
[string]$Virtual_Machine,
[uint16]$Virtual_Machine_Id,
[uint16]$Interface_Id,
[object]$Status,
[object]$Role,
[switch]$Raw
2018-05-11 15:54:43 -04:00
)
2020-03-23 12:18:01 -04:00
if ($null -ne $Family) {
$PSBoundParameters.Family = ValidateIPAMChoice -ProvidedValue $Family -IPAddressFamily
}
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
if ($null -ne $Status) {
$PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -IPAddressStatus
}
if ($null -ne $Role) {
$PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -IPAddressRole
}
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
2018-05-11 15:54:43 -04:00
2018-05-16 10:54:20 -04:00
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
2018-05-14 16:46:12 -04:00
2020-03-23 12:18:01 -04:00
InvokeNetboxRequest -URI $uri -Raw:$Raw
2018-05-11 15:54:43 -04:00
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-New-NetboxIPAMAddress_ps1
<#
.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.
#>
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
function New-NetboxIPAMAddress {
<#
.SYNOPSIS
Create a new IP address to Netbox
.DESCRIPTION
Create a new IP address to Netbox with a status of Active by default.
.PARAMETER Address
IP address in CIDR notation: 192.168.1.1/24
.PARAMETER Status
Status of the IP. Defaults to Active
.PARAMETER Tenant
Tenant ID
.PARAMETER VRF
VRF ID
.PARAMETER Role
Role such as anycast, loopback, etc... Defaults to nothing
.PARAMETER NAT_Inside
ID of IP for NAT
.PARAMETER Custom_Fields
Custom field hash table. Will be validated by the API service
.PARAMETER Interface
ID of interface to apply IP
.PARAMETER Description
Description of IP address
.PARAMETER Raw
Return raw results from API service
.EXAMPLE
PS C:\> Create-NetboxIPAMAddress
.NOTES
Additional information about the function.
#>
2018-05-11 15:54:43 -04:00
[CmdletBinding()]
2020-03-23 12:18:01 -04:00
[OutputType([pscustomobject])]
2018-05-11 15:54:43 -04:00
param
(
[Parameter(Mandatory = $true)]
2020-03-23 12:18:01 -04:00
[string]$Address,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[object]$Status = 'Active',
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$Tenant,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$VRF,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[object]$Role,
[uint16]$NAT_Inside,
[hashtable]$Custom_Fields,
[uint16]$Interface,
2018-05-11 15:54:43 -04:00
[string]$Description,
[switch]$Raw
)
2020-03-23 12:18:01 -04:00
$PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -IPAddressStatus
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
if ($null -ne $Role) {
$PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -IPAddressRole
}
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
$segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
$URIComponents = BuildURIComponents -URISegments $segments -ParametersDictionary $PSBoundParameters
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
$URI = BuildNewURI -Segments $URIComponents.Segments
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters -Raw:$Raw
2018-05-11 15:54:43 -04:00
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-New-NetboxIPAMPrefix_ps1
<#
.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.
#>
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
function New-NetboxIPAMPrefix {
[CmdletBinding()]
2018-05-18 12:14:27 -04:00
param
(
2020-03-23 12:18:01 -04:00
[Parameter(Mandatory = $true)]
[string]$Prefix,
2018-05-18 12:14:27 -04:00
2020-03-23 12:18:01 -04:00
[object]$Status = 'Active',
2018-05-18 12:14:27 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$Tenant,
2018-05-18 12:14:27 -04:00
2020-03-23 12:18:01 -04:00
[object]$Role,
2018-05-18 12:14:27 -04:00
2020-03-23 12:18:01 -04:00
[bool]$IsPool,
2018-05-18 12:14:27 -04:00
2020-03-23 12:18:01 -04:00
[string]$Description,
2018-05-18 12:14:27 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$Site,
2018-05-18 12:14:27 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$VRF,
2018-05-18 12:14:27 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$VLAN,
2018-05-18 12:14:27 -04:00
[hashtable]$Custom_Fields,
2020-03-23 12:18:01 -04:00
[switch]$Raw
2018-05-18 12:14:27 -04:00
)
2020-03-23 12:18:01 -04:00
$PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -PrefixStatus
<#
# As of 2018/10/18, this does not appear to be a validated IPAM choice
if ($null -ne $Role) {
$PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -PrefixRole
2018-05-18 12:14:27 -04:00
}
2020-03-23 12:18:01 -04:00
#>
2018-05-18 12:14:27 -04:00
2020-03-23 12:18:01 -04:00
$segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes'))
2018-05-18 12:14:27 -04:00
2020-03-23 12:18:01 -04:00
$URIComponents = BuildURIComponents -URISegments $segments -ParametersDictionary $PSBoundParameters
2018-05-18 12:14:27 -04:00
2020-03-23 12:18:01 -04:00
$URI = BuildNewURI -Segments $URIComponents.Segments
2018-05-18 12:14:27 -04:00
2020-03-23 12:18:01 -04:00
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters -Raw:$Raw
2018-05-18 12:14:27 -04:00
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-Remove-NetboxIPAMAddress_ps1
<#
.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.
#>
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
function Remove-NetboxIPAMAddress {
<#
.SYNOPSIS
Remove an IP address from Netbox
.DESCRIPTION
Removes/deletes an IP address from Netbox by ID and optional other filters
.PARAMETER Id
Database ID of the IP address object.
.PARAMETER Force
Do not confirm.
.EXAMPLE
PS C:\> Remove-NetboxIPAMAddress -Id $value1
.NOTES
Additional information about the function.
#>
[CmdletBinding(ConfirmImpact = 'High',
2018-05-21 15:36:04 -04:00
SupportsShouldProcess = $true)]
param
(
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true)]
[uint16[]]$Id,
[switch]$Force
)
begin {
}
process {
2020-03-23 12:18:01 -04:00
foreach ($IPId in $Id) {
$CurrentIP = Get-NetboxIPAMAddress -Id $IPId -ErrorAction Stop
2018-05-21 15:36:04 -04:00
2020-03-23 12:18:01 -04:00
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses', $IPId))
2018-05-21 15:36:04 -04:00
2020-03-23 12:18:01 -04:00
if ($Force -or $pscmdlet.ShouldProcess($CurrentIP.Address, "Delete")) {
$URI = BuildNewURI -Segments $Segments
2018-05-21 15:36:04 -04:00
2020-03-23 12:18:01 -04:00
InvokeNetboxRequest -URI $URI -Method DELETE
2018-05-21 15:36:04 -04:00
}
}
}
end {
}
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-Set-NetboxIPAMAddress_ps1
<#
.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.
#>
2018-05-21 15:36:04 -04:00
2020-03-23 12:18:01 -04:00
function Set-NetboxIPAMAddress {
[CmdletBinding(ConfirmImpact = 'Medium',
2018-05-29 10:43:23 -04:00
SupportsShouldProcess = $true)]
param
(
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true)]
[uint16[]]$Id,
2020-03-23 12:18:01 -04:00
[string]$Address,
[object]$Status,
[uint16]$Tenant,
[uint16]$VRF,
[object]$Role,
[uint16]$NAT_Inside,
[hashtable]$Custom_Fields,
[uint16]$Interface,
[string]$Description,
2018-05-29 10:43:23 -04:00
[switch]$Force
)
begin {
2020-03-23 12:18:01 -04:00
if ($Status) {
$PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -IPAddressStatus
}
2018-05-29 10:43:23 -04:00
2020-03-23 12:18:01 -04:00
if ($Role) {
$PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -IPAddressRole
}
2018-05-29 10:43:23 -04:00
}
process {
2020-03-23 12:18:01 -04:00
foreach ($IPId in $Id) {
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses', $IPId))
Write-Verbose "Obtaining IPs from ID $IPId"
$CurrentIP = Get-NetboxIPAMAddress -Id $IPId -ErrorAction Stop
2018-05-29 10:43:23 -04:00
2020-03-23 12:18:01 -04:00
if ($Force -or $PSCmdlet.ShouldProcess($CurrentIP.Address, 'Set')) {
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
2018-05-29 10:43:23 -04:00
2020-03-23 12:18:01 -04:00
$URI = BuildNewURI -Segments $URIComponents.Segments
2018-05-29 10:43:23 -04:00
2020-03-23 12:18:01 -04:00
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
2018-05-29 10:43:23 -04:00
}
}
}
end {
}
}
2020-03-23 12:18:01 -04:00
#endregion
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
#region Invoke-Get-NetboxIPAMChoices_ps1
2018-05-11 15:54:43 -04:00
<#
.NOTES
===========================================================================
2020-03-23 12:18:01 -04:00
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
Created on: 3/19/2020 11:54
Created by: Claussen
2018-05-11 15:54:43 -04:00
Organization: NEOnet
2020-03-23 12:18:01 -04:00
Filename: Get-NetboxIPAMChoices.ps1
2018-05-11 15:54:43 -04:00
===========================================================================
.DESCRIPTION
2020-03-23 12:18:01 -04:00
A description of the file.
2018-05-11 15:54:43 -04:00
#>
2020-03-23 12:18:01 -04:00
2018-05-11 15:54:43 -04:00
function Get-NetboxIPAMChoices {
[CmdletBinding()]
2018-05-18 12:41:01 -04:00
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Justification = "These are literally 'choices' in Netbox")]
2018-05-11 15:54:43 -04:00
param ()
$uriSegments = [System.Collections.ArrayList]::new(@('ipam', '_choices'))
$uri = BuildNewURI -Segments $uriSegments -Parameters $Parameters
InvokeNetboxRequest -URI $uri
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-Get-NetboxTenant_ps1
<#
.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.
#>
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
function Get-NetboxTenant {
2018-05-11 15:54:43 -04:00
[CmdletBinding()]
param
(
[uint16]$Limit,
[uint16]$Offset,
2020-03-23 12:18:01 -04:00
[string]$Name,
2018-05-11 15:54:43 -04:00
[uint16[]]$Id,
[string]$Query,
2020-03-23 12:18:01 -04:00
[string]$Group,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$GroupID,
[hashtable]$CustomFields,
2018-05-11 15:54:43 -04:00
[switch]$Raw
)
2020-03-23 12:18:01 -04:00
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'tenants'))
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
2018-05-11 15:54:43 -04:00
2018-05-14 16:46:12 -04:00
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
2018-05-11 15:54:43 -04:00
InvokeNetboxRequest -URI $uri -Raw:$Raw
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-Get-NetboxTenancyChoices_ps1
<#
.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-NetboxTenancyChoices.ps1
===========================================================================
.DESCRIPTION
A description of the file.
#>
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
function Get-NetboxTenancyChoices {
2018-05-11 15:54:43 -04:00
[CmdletBinding()]
2020-03-23 12:18:01 -04:00
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Justification = "These are literally 'choices' in Netbox")]
param ()
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
$uriSegments = [System.Collections.ArrayList]::new(@('tenancy', '_choices'))
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
$uri = BuildNewURI -Segments $uriSegments
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
InvokeNetboxRequest -URI $uri
2018-05-11 15:54:43 -04:00
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-Get-NetboxVirtualMachine_ps1
<#
.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.
2018-05-11 15:54:43 -04:00
#>
2020-03-23 12:18:01 -04:00
function Get-NetboxVirtualMachine {
2018-05-11 16:33:26 -04:00
<#
.SYNOPSIS
2020-03-23 12:18:01 -04:00
Obtains virtual machines from Netbox.
2018-05-11 16:33:26 -04:00
.DESCRIPTION
2020-03-23 12:18:01 -04:00
Obtains one or more virtual machines based on provided filters.
2018-05-11 16:33:26 -04:00
.PARAMETER Limit
2020-03-23 12:18:01 -04:00
Number of results to return per page
2018-05-11 16:33:26 -04:00
.PARAMETER Offset
2020-03-23 12:18:01 -04:00
The initial index from which to return the results
2018-05-11 16:33:26 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER Query
A general query used to search for a VM
2018-05-11 16:33:26 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER Name
Name of the VM
2018-05-11 16:33:26 -04:00
.PARAMETER Id
2020-03-23 12:18:01 -04:00
Database ID of the VM
2018-05-11 16:33:26 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER Status
Status of the VM
2018-05-11 16:33:26 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER Tenant
String value of tenant
.PARAMETER Tenant_ID
Database ID of the tenant.
2018-05-11 16:33:26 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER Platform
String value of the platform
2018-05-11 16:33:26 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER Platform_ID
Database ID of the platform
2018-05-11 16:33:26 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER Cluster_Group
String value of the cluster group.
2018-05-11 16:33:26 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER Cluster_Group_Id
Database ID of the cluster group.
2018-05-11 16:33:26 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER Cluster_Type
String value of the Cluster type.
2018-05-11 16:33:26 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER Cluster_Type_Id
Database ID of the cluster type.
2018-05-11 16:33:26 -04:00
2020-03-23 12:18:01 -04:00
.PARAMETER Cluster_Id
Database ID of the cluster.
2018-05-11 16:33:26 -04:00
.PARAMETER Site
2020-03-23 12:18:01 -04:00
String value of the site.
2018-05-11 16:33:26 -04:00
.PARAMETER Site_Id
2020-03-23 12:18:01 -04:00
Database ID of the site.
2018-05-11 16:33:26 -04:00
.PARAMETER Role
2020-03-23 12:18:01 -04:00
String value of the role.
2018-05-11 16:33:26 -04:00
.PARAMETER Role_Id
2020-03-23 12:18:01 -04:00
Database ID of the role.
2018-05-11 16:33:26 -04:00
.PARAMETER Raw
A description of the Raw parameter.
2020-03-23 12:18:01 -04:00
.PARAMETER TenantID
Database ID of tenant
.PARAMETER PlatformID
Database ID of the platform
.PARAMETER id__in
Database IDs of VMs
2018-05-11 16:33:26 -04:00
.EXAMPLE
2020-03-23 12:18:01 -04:00
PS C:\> Get-NetboxVirtualMachine
2018-05-11 16:33:26 -04:00
.NOTES
Additional information about the function.
#>
2018-05-11 15:54:43 -04:00
[CmdletBinding()]
param
(
[uint16]$Limit,
[uint16]$Offset,
2020-03-23 12:18:01 -04:00
[Alias('q')]
[string]$Query,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[string]$Name,
2018-05-11 16:33:26 -04:00
2018-05-11 15:54:43 -04:00
[uint16[]]$Id,
2020-03-23 12:18:01 -04:00
[object]$Status,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[string]$Tenant,
2018-05-11 16:33:26 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$Tenant_ID,
2018-05-11 16:33:26 -04:00
2020-03-23 12:18:01 -04:00
[string]$Platform,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$Platform_ID,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[string]$Cluster_Group,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$Cluster_Group_Id,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[string]$Cluster_Type,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$Cluster_Type_Id,
[uint16]$Cluster_Id,
2018-05-11 15:54:43 -04:00
[string]$Site,
[uint16]$Site_Id,
[string]$Role,
[uint16]$Role_Id,
[switch]$Raw
)
2018-05-18 12:14:27 -04:00
if ($null -ne $Status) {
2020-03-23 12:18:01 -04:00
$PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
2018-05-11 15:54:43 -04:00
}
2020-03-23 12:18:01 -04:00
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines'))
2018-05-11 15:54:43 -04:00
2018-05-16 10:54:20 -04:00
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
2018-05-11 15:54:43 -04:00
2018-05-14 16:46:12 -04:00
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
InvokeNetboxRequest -URI $uri -Raw:$Raw
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-New-NetboxVirtualMachine_ps1
<#
.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.
#>
2018-05-14 16:46:12 -04:00
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
function New-NetboxVirtualMachine {
2018-05-16 10:54:20 -04:00
[CmdletBinding()]
2018-05-14 16:46:12 -04:00
[OutputType([pscustomobject])]
param
(
[Parameter(Mandatory = $true)]
2020-03-23 12:18:01 -04:00
[string]$Name,
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
[Parameter(Mandatory = $true)]
[uint16]$Cluster,
2018-05-14 16:46:12 -04:00
[uint16]$Tenant,
2020-03-23 12:18:01 -04:00
[object]$Status = 'Active',
2018-05-14 16:46:12 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$Role,
2018-05-14 16:46:12 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$Platform,
2018-05-14 16:46:12 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$vCPUs,
2018-05-14 16:46:12 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$Memory,
2018-05-14 16:46:12 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$Disk,
2018-05-14 16:46:12 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$Primary_IP4,
[uint16]$Primary_IP6,
[hashtable]$Custom_Fields,
[string]$Comments
2018-05-14 16:46:12 -04:00
)
2020-03-23 12:18:01 -04:00
$PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
2018-05-16 10:54:20 -04:00
2020-03-23 12:18:01 -04:00
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines'))
2018-05-16 10:54:20 -04:00
2020-03-23 12:18:01 -04:00
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
2018-05-11 15:54:43 -04:00
2018-05-14 16:46:12 -04:00
$URI = BuildNewURI -Segments $URIComponents.Segments
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters
2018-05-11 15:54:43 -04:00
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-Set-NetboxVirtualMachine_ps1
<#
.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.
#>
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
function Set-NetboxVirtualMachine {
[CmdletBinding(ConfirmImpact = 'Medium',
SupportsShouldProcess = $true)]
2018-05-16 10:54:20 -04:00
param
(
2020-03-23 12:18:01 -04:00
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true)]
[uint16]$Id,
2018-05-16 10:54:20 -04:00
2020-03-23 12:18:01 -04:00
[string]$Name,
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
[uint16]$Role,
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
[uint16]$Cluster,
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
[object]$Status,
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
[uint16]$Platform,
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
[uint16]$Primary_IP4,
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
[uint16]$Primary_IP6,
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
[byte]$VCPUs,
[uint16]$Memory,
[uint16]$Disk,
[uint16]$Tenant,
[string]$Comments,
2019-12-10 15:09:42 -05:00
[hashtable]$Custom_Fields,
2020-03-23 12:18:01 -04:00
[switch]$Force
2019-12-10 15:09:42 -05:00
)
2020-03-23 12:18:01 -04:00
if ($null -ne $Status) {
$PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
2019-12-10 15:09:42 -05:00
}
2020-03-23 12:18:01 -04:00
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines', $Id))
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
Write-Verbose "Obtaining VM from ID $Id"
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
$CurrentVM = Get-NetboxVirtualMachine -Id $Id -ErrorAction Stop
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
Write-Verbose "Finished obtaining VM"
if ($Force -or $pscmdlet.ShouldProcess($CurrentVM.Name, "Set")) {
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
$URI = BuildNewURI -Segments $URIComponents.Segments
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
}
2019-12-10 15:09:42 -05:00
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-Add-NetboxVirtualMachineInterface_ps1
<#
.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.
#>
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
function Add-NetboxVirtualMachineInterface {
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true)]
[string]$Name,
[Parameter(Mandatory = $true)]
[uint16]$Virtual_Machine,
[boolean]$Enabled = $true,
[string]$MAC_Address,
[uint16]$MTU,
[string]$Description,
[switch]$Raw
)
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'interfaces'))
$PSBoundParameters.Enabled = $Enabled
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
$uri = BuildNewURI -Segments $URIComponents.Segments
InvokeNetboxRequest -URI $uri -Method POST -Body $URIComponents.Parameters
}
#endregion
#region Invoke-Get-NetboxVirtualMachineInterface_ps1
<#
.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.
#>
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
function Get-NetboxVirtualMachineInterface {
2019-12-10 15:09:42 -05:00
<#
.SYNOPSIS
2020-03-23 12:18:01 -04:00
Gets VM interfaces
2019-12-10 15:09:42 -05:00
.DESCRIPTION
2020-03-23 12:18:01 -04:00
Obtains the interface objects for one or more VMs
.PARAMETER Limit
Number of results to return per page.
.PARAMETER Offset
The initial index from which to return the results.
2019-12-10 15:09:42 -05:00
.PARAMETER Id
2020-03-23 12:18:01 -04:00
Database ID of the interface
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
.PARAMETER Name
Name of the interface
.PARAMETER Enabled
True/False if the interface is enabled
.PARAMETER MTU
Maximum Transmission Unit size. Generally 1500 or 9000
.PARAMETER Virtual_Machine_Id
ID of the virtual machine to which the interface(s) are assigned.
.PARAMETER Virtual_Machine
Name of the virtual machine to get interfaces
.PARAMETER MAC_Address
MAC address assigned to the interface
.PARAMETER Raw
A description of the Raw parameter.
2019-12-10 15:09:42 -05:00
.EXAMPLE
2020-03-23 12:18:01 -04:00
PS C:\> Get-NetboxVirtualMachineInterface
2019-12-10 15:09:42 -05:00
.NOTES
Additional information about the function.
#>
2020-03-23 12:18:01 -04:00
[CmdletBinding()]
2019-12-10 15:09:42 -05:00
param
(
2020-03-23 12:18:01 -04:00
[uint16]$Limit,
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
[uint16]$Offset,
[Parameter(ValueFromPipeline = $true)]
[uint16]$Id,
[string]$Name,
[boolean]$Enabled,
[uint16]$MTU,
[uint16]$Virtual_Machine_Id,
[string]$Virtual_Machine,
[string]$MAC_Address,
[switch]$Raw
2018-05-16 10:54:20 -04:00
)
2020-03-23 12:18:01 -04:00
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'interfaces'))
2018-05-16 10:54:20 -04:00
2020-03-23 12:18:01 -04:00
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
2018-05-29 10:43:23 -04:00
2020-03-23 12:18:01 -04:00
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
InvokeNetboxRequest -URI $uri -Raw:$Raw
2018-05-16 10:54:20 -04:00
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-Set-NetboxVirtualMachineInterface_ps1
<#
.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.
#>
2018-05-11 15:54:43 -04:00
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
function Set-NetboxVirtualMachineInterface {
2018-05-29 10:43:23 -04:00
[CmdletBinding(ConfirmImpact = 'Medium',
2018-05-16 10:54:20 -04:00
SupportsShouldProcess = $true)]
2020-03-23 12:18:01 -04:00
[OutputType([pscustomobject])]
2018-05-16 10:54:20 -04:00
param
(
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true)]
2018-05-29 10:43:23 -04:00
[uint16[]]$Id,
2018-05-16 10:54:20 -04:00
2020-03-23 12:18:01 -04:00
[string]$Name,
2018-05-16 10:54:20 -04:00
2020-03-23 12:18:01 -04:00
[string]$MAC_Address,
2018-05-16 10:54:20 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$MTU,
2018-05-16 10:54:20 -04:00
2020-03-23 12:18:01 -04:00
[string]$Description,
2018-05-16 10:54:20 -04:00
2020-03-23 12:18:01 -04:00
[boolean]$Enabled,
2018-05-16 10:54:20 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$Virtual_Machine,
2018-05-16 10:54:20 -04:00
[switch]$Force
)
2018-05-29 10:43:23 -04:00
begin {
2018-05-18 12:14:27 -04:00
}
2018-05-16 10:54:20 -04:00
2020-03-23 12:18:01 -04:00
process {
foreach ($VMI_ID in $Id) {
Write-Verbose "Obtaining VM Interface..."
$CurrentVMI = Get-NetboxVirtualMachineInterface -Id $VMI_ID -ErrorAction Stop
Write-Verbose "Finished obtaining VM Interface"
2018-05-29 10:43:23 -04:00
2020-03-23 12:18:01 -04:00
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'interfaces', $CurrentVMI.Id))
2018-05-29 10:43:23 -04:00
2020-03-23 12:18:01 -04:00
if ($Force -or $pscmdlet.ShouldProcess("Interface $($CurrentVMI.Id) on VM $($CurrentVMI.Virtual_Machine.Name)", "Set")) {
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
2018-05-29 10:43:23 -04:00
$URI = BuildNewURI -Segments $URIComponents.Segments
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
}
}
2018-05-16 10:54:20 -04:00
}
2020-03-23 12:18:01 -04:00
end {
2018-05-16 10:54:20 -04:00
}
}
2020-03-23 12:18:01 -04:00
#endregion
2018-05-29 10:43:23 -04:00
2020-03-23 12:18:01 -04:00
#region Invoke-Get-NetboxVirtualizationChoices_ps1
2018-05-29 10:43:23 -04:00
<#
.NOTES
===========================================================================
2020-03-23 12:18:01 -04:00
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
Created on: 3/19/2020 14:10
Created by: Claussen
2018-05-29 10:43:23 -04:00
Organization: NEOnet
2020-03-23 12:18:01 -04:00
Filename: Get-NetboxVirtualizationChoices.ps1
2018-05-29 10:43:23 -04:00
===========================================================================
.DESCRIPTION
A description of the file.
#>
2020-03-23 12:18:01 -04:00
function Get-NetboxVirtualizationChoices {
2018-05-29 10:43:23 -04:00
[CmdletBinding()]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Justification = "These are literally 'choices' in Netbox")]
param ()
2020-03-23 12:18:01 -04:00
$uriSegments = [System.Collections.ArrayList]::new(@('virtualization', '_choices'))
2018-05-29 10:43:23 -04:00
2020-03-23 12:18:01 -04:00
$uri = BuildNewURI -Segments $uriSegments
2018-05-29 10:43:23 -04:00
InvokeNetboxRequest -URI $uri
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-Get-NetboxVirtualizationCluster_ps1
<#
.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.
#>
2018-05-29 10:43:23 -04:00
2020-03-23 12:18:01 -04:00
function Get-NetboxVirtualizationCluster {
<#
.SYNOPSIS
Obtains virtualization clusters from Netbox.
.DESCRIPTION
Obtains one or more virtualization clusters based on provided filters.
.PARAMETER Limit
Number of results to return per page
.PARAMETER Offset
The initial index from which to return the results
.PARAMETER Query
A general query used to search for a cluster
.PARAMETER Name
Name of the cluster
.PARAMETER Id
Database ID(s) of the cluster
.PARAMETER Group
String value of the cluster group.
.PARAMETER Group_Id
Database ID of the cluster group.
.PARAMETER Type
String value of the Cluster type.
.PARAMETER Type_Id
Database ID of the cluster type.
.PARAMETER Site
String value of the site.
.PARAMETER Site_Id
Database ID of the site.
.PARAMETER Raw
A description of the Raw parameter.
.EXAMPLE
PS C:\> Get-NetboxVirtualizationCluster
.NOTES
Additional information about the function.
#>
2018-05-29 10:43:23 -04:00
[CmdletBinding()]
param
(
[uint16]$Limit,
[uint16]$Offset,
2020-03-23 12:18:01 -04:00
[Alias('q')]
[string]$Query,
2018-05-29 10:43:23 -04:00
[string]$Name,
2020-03-23 12:18:01 -04:00
[Alias('id__in')]
[uint16[]]$Id,
2018-05-29 10:43:23 -04:00
2020-03-23 12:18:01 -04:00
[string]$Group,
2018-05-29 10:43:23 -04:00
2020-03-23 12:18:01 -04:00
[uint16]$Group_Id,
[string]$Type,
[uint16]$Type_Id,
[string]$Site,
[uint16]$Site_Id,
2018-05-29 10:43:23 -04:00
[switch]$Raw
)
2020-03-23 12:18:01 -04:00
$uriSegments = [System.Collections.ArrayList]::new(@('virtualization', 'clusters'))
$URIParameters = @{
}
foreach ($CmdletParameterName in $PSBoundParameters.Keys) {
if ($CmdletParameterName -in $CommonParameterNames) {
# These are common parameters and should not be appended to the URI
Write-Debug "Skipping parameter $CmdletParameterName"
continue
2018-05-29 10:43:23 -04:00
}
2020-03-23 12:18:01 -04:00
if ($CmdletParameterName -eq 'Id') {
# Check if there is one or more values for Id and build a URI or query as appropriate
if (@($PSBoundParameters[$CmdletParameterName]).Count -gt 1) {
$URIParameters['id__in'] = $Id -join ','
} else {
[void]$uriSegments.Add($PSBoundParameters[$CmdletParameterName])
}
} elseif ($CmdletParameterName -eq 'Query') {
$URIParameters['q'] = $PSBoundParameters[$CmdletParameterName]
} else {
$URIParameters[$CmdletParameterName.ToLower()] = $PSBoundParameters[$CmdletParameterName]
2018-05-29 10:43:23 -04:00
}
}
2020-03-23 12:18:01 -04:00
$uri = BuildNewURI -Segments $uriSegments -Parameters $URIParameters
InvokeNetboxRequest -URI $uri -Raw:$Raw
2018-05-29 10:43:23 -04:00
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-ValidateVirtualizationChoice_ps1
<#
.NOTES
===========================================================================
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
Created on: 3/19/2020 14:12
Created by: Claussen
Organization: NEOnet
Filename: ValidateVirtualizationChoice.ps1
===========================================================================
.DESCRIPTION
A description of the file.
#>
2018-05-29 10:43:23 -04:00
2020-03-23 12:18:01 -04:00
function ValidateVirtualizationChoice {
<#
.SYNOPSIS
Internal function to verify provided values for static choices
.DESCRIPTION
When users connect to the API, choices for each major object are cached to the config variable.
These values are then utilized to verify if the provided value from a user is valid.
.PARAMETER ProvidedValue
The value to validate against static choices
.PARAMETER AggregateFamily
Verify against aggregate family values
.PARAMETER PrefixFamily
Verify against prefix family values
.PARAMETER PrefixStatus
Verify against prefix status values
.PARAMETER IPAddressFamily
Verify against ip-address family values
.PARAMETER IPAddressStatus
Verify against ip-address status values
.PARAMETER IPAddressRole
Verify against ip-address role values
.PARAMETER VLANStatus
Verify against VLAN status values
.PARAMETER ServiceProtocol
Verify against service protocol values
.EXAMPLE
PS C:\> VerifyIPAMChoices -ProvidedValue 'loopback' -IPAddressRole
.EXAMPLE
PS C:\> VerifyIPAMChoices -ProvidedValue 'Loopback' -IPAddressFamily
>> Invalid value Loopback for ip-address:family. Must be one of: 4, 6, IPv4, IPv6
.FUNCTIONALITY
This cmdlet is intended to be used internally and not exposed to the user
.OUTPUT
This function returns nothing if the value is valid. Otherwise, it will throw an error.
#>
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true)]
[object]$ProvidedValue,
[Parameter(ParameterSetName = 'virtual-machine:status',
Mandatory = $true)]
[switch]$VirtualMachineStatus
)
ValidateChoice -MajorObject 'Virtualization' -ChoiceName $PSCmdlet.ParameterSetName -ProvidedValue $ProvidedValue
}
#endregion
2018-05-29 10:43:23 -04:00
2020-03-23 12:18:01 -04:00
#region Invoke-Get-NetboxDCIMDevice_ps1
2018-05-29 10:43:23 -04:00
<#
.NOTES
===========================================================================
2020-03-23 12:18:01 -04:00
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
Created on: 3/23/2020 12:06
Created by: Claussen
2018-05-29 10:43:23 -04:00
Organization: NEOnet
2020-03-23 12:18:01 -04:00
Filename: Get-NetboxDCIMDevice.ps1
2018-05-29 10:43:23 -04:00
===========================================================================
.DESCRIPTION
A description of the file.
#>
function Get-NetboxDCIMDevice {
[CmdletBinding()]
#region Parameters
param
(
[uint16]$Limit,
[uint16]$Offset,
[Parameter(ValueFromPipelineByPropertyName = $true)]
[uint16[]]$Id,
[string]$Query,
[string]$Name,
[uint16]$Manufacturer_Id,
[string]$Manufacturer,
[uint16]$Device_Type_Id,
[uint16]$Role_Id,
[string]$Role,
[uint16]$Tenant_Id,
[string]$Tenant,
[uint16]$Platform_Id,
[string]$Platform,
[string]$Asset_Tag,
[uint16]$Site_Id,
[string]$Site,
[uint16]$Rack_Group_Id,
[uint16]$Rack_Id,
[uint16]$Cluster_Id,
[uint16]$Model,
[object]$Status,
[bool]$Is_Full_Depth,
[bool]$Is_Console_Server,
[bool]$Is_PDU,
[bool]$Is_Network_Device,
[string]$MAC_Address,
[bool]$Has_Primary_IP,
[uint16]$Virtual_Chassis_Id,
[uint16]$Position,
[string]$Serial,
[switch]$Raw
)
#endregion Parameters
if ($null -ne $Status) {
$PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
}
$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
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-Get-NetboxDCIMDeviceType_ps1
<#
.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.
#>
2018-05-29 10:43:23 -04:00
function Get-NetboxDCIMDeviceType {
[CmdletBinding()]
#region Parameters
param
(
[uint16]$Offset,
[uint16]$Limit,
[uint16[]]$Id,
[string]$Query,
[string]$Slug,
[string]$Manufacturer,
[uint16]$Manufacturer_Id,
[string]$Model,
[string]$Part_Number,
[uint16]$U_Height,
[bool]$Is_Full_Depth,
[bool]$Is_Console_Server,
[bool]$Is_PDU,
[bool]$Is_Network_Device,
[uint16]$Subdevice_Role,
[switch]$Raw
)
#endregion Parameters
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'device-types'))
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
InvokeNetboxRequest -URI $URI -Raw:$Raw
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-Get-NetboxDCIMDeviceRole_ps1
<#
.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.
#>
2018-05-29 10:43:23 -04:00
function Get-NetboxDCIMDeviceRole {
[CmdletBinding()]
param
(
[uint16]$Limit,
[uint16]$Offset,
[Parameter(ParameterSetName = 'ById')]
[uint16[]]$Id,
[string]$Name,
[string]$Slug,
[string]$Color,
[bool]$VM_Role,
[switch]$Raw
)
switch ($PSCmdlet.ParameterSetName) {
'ById' {
foreach ($DRId in $Id) {
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'device-roles', $DRId))
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Raw'
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
InvokeNetboxRequest -URI $URI -Raw:$Raw
}
break
}
default {
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'device-roles'))
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
InvokeNetboxRequest -URI $URI -Raw:$Raw
}
}
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-New-NetboxDCIMDevice_ps1
<#
.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 {
[CmdletBinding()]
[OutputType([pscustomobject])]
#region Parameters
2018-05-29 10:43:23 -04:00
param
(
[Parameter(Mandatory = $true)]
[string]$Name,
[Parameter(Mandatory = $true)]
[object]$Device_Role,
[Parameter(Mandatory = $true)]
[object]$Device_Type,
[Parameter(Mandatory = $true)]
[uint16]$Site,
[object]$Status = 'Active',
[uint16]$Platform,
[uint16]$Tenant,
[uint16]$Cluster,
[uint16]$Rack,
[uint16]$Position,
[object]$Face,
[string]$Serial,
[string]$Asset_Tag,
[uint16]$Virtual_Chassis,
[uint16]$VC_Priority,
[uint16]$VC_Position,
[uint16]$Primary_IP4,
[uint16]$Primary_IP6,
[string]$Comments,
[hashtable]$Custom_Fields
)
#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'))
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
$URI = BuildNewURI -Segments $URIComponents.Segments
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-Set-NetboxDCIMDevice_ps1
<#
.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.
#>
2018-05-29 10:43:23 -04:00
function Set-NetboxDCIMDevice {
[CmdletBinding(SupportsShouldProcess = $true)]
param
(
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true)]
[uint16[]]$Id,
[string]$Name,
[object]$Device_Role,
[object]$Device_Type,
[uint16]$Site,
[object]$Status,
[uint16]$Platform,
[uint16]$Tenant,
[uint16]$Cluster,
[uint16]$Rack,
[uint16]$Position,
[object]$Face,
[string]$Serial,
[string]$Asset_Tag,
[uint16]$Virtual_Chassis,
[uint16]$VC_Priority,
[uint16]$VC_Position,
[uint16]$Primary_IP4,
[uint16]$Primary_IP6,
[string]$Comments,
[hashtable]$Custom_Fields,
[switch]$Force
)
begin {
if ($null -ne $Status) {
$PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
}
if ($null -ne $Face) {
$PSBoundParameters.Face = ValidateDCIMChoice -ProvidedValue $Face -DeviceFace
}
}
process {
foreach ($DeviceID in $Id) {
$CurrentDevice = Get-NetboxDCIMDevice -Id $DeviceID -ErrorAction Stop
if ($Force -or $pscmdlet.ShouldProcess("$($CurrentDevice.Name)", "Set")) {
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'devices', $CurrentDevice.Id))
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
$URI = BuildNewURI -Segments $URIComponents.Segments
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
}
}
}
end {
}
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-Remove-NetboxDCIMDevice_ps1
<#
.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.
#>
2018-05-29 10:43:23 -04:00
function Remove-NetboxDCIMDevice {
<#
.SYNOPSIS
Delete a device
.DESCRIPTION
Deletes a device from Netbox by ID
.PARAMETER Id
Database ID of the device
.PARAMETER Force
Force deletion without any prompts
.EXAMPLE
PS C:\> Remove-NetboxDCIMDevice -Id $value1
.NOTES
Additional information about the function.
#>
[CmdletBinding(ConfirmImpact = 'High',
SupportsShouldProcess = $true)]
param
(
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true)]
[uint16[]]$Id,
[switch]$Force
)
begin {
}
process {
foreach ($DeviceID in $Id) {
$CurrentDevice = Get-NetboxDCIMDevice -Id $DeviceID -ErrorAction Stop
if ($Force -or $pscmdlet.ShouldProcess("Name: $($CurrentDevice.Name) | ID: $($CurrentDevice.Id)", "Remove")) {
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'devices', $CurrentDevice.Id))
$URI = BuildNewURI -Segments $Segments
InvokeNetboxRequest -URI $URI -Method DELETE
}
}
}
end {
}
}
2020-03-23 12:18:01 -04:00
#endregion
2018-05-29 10:43:23 -04:00
2020-03-23 12:18:01 -04:00
#region Invoke-Get-NetboxDCIMInterface_ps1
2018-05-29 10:43:23 -04:00
<#
.NOTES
===========================================================================
2020-03-23 12:18:01 -04:00
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
Created on: 3/23/2020 12:09
Created by: Claussen
2018-05-29 10:43:23 -04:00
Organization: NEOnet
2020-03-23 12:18:01 -04:00
Filename: Get-NetboxDCIMInterface.ps1
2018-05-29 10:43:23 -04:00
===========================================================================
.DESCRIPTION
A description of the file.
#>
function Get-NetboxDCIMInterface {
[CmdletBinding()]
[OutputType([pscustomobject])]
param
(
[uint16]$Limit,
[uint16]$Offset,
[Parameter(ValueFromPipelineByPropertyName = $true)]
[uint16]$Id,
[uint16]$Name,
[object]$Form_Factor,
[bool]$Enabled,
[uint16]$MTU,
[bool]$MGMT_Only,
[string]$Device,
[uint16]$Device_Id,
[uint16]$Type,
[uint16]$LAG_Id,
[string]$MAC_Address,
[switch]$Raw
)
if ($null -ne $Form_Factor) {
$PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
}
$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
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-Get-NetboxDCIMInterfaceConnection_ps1
<#
.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.
#>
2018-05-29 10:43:23 -04:00
function Get-NetboxDCIMInterfaceConnection {
[CmdletBinding()]
[OutputType([pscustomobject])]
param
(
[uint16]$Limit,
[uint16]$Offset,
[uint16]$Id,
[object]$Connection_Status,
[uint16]$Site,
[uint16]$Device,
[switch]$Raw
)
if ($null -ne $Connection_Status) {
$PSBoundParameters.Connection_Status = ValidateDCIMChoice -ProvidedValue $Connection_Status -InterfaceConnectionStatus
}
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interface-connections'))
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
InvokeNetboxRequest -URI $URI -Raw:$Raw
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-Add-NetboxDCIMInterface_ps1
<#
.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.
#>
2018-05-29 10:43:23 -04:00
function Add-NetboxDCIMInterface {
[CmdletBinding()]
[OutputType([pscustomobject])]
param
(
[Parameter(Mandatory = $true)]
[uint16]$Device,
[Parameter(Mandatory = $true)]
[string]$Name,
[bool]$Enabled,
[object]$Form_Factor,
[uint16]$MTU,
[string]$MAC_Address,
[bool]$MGMT_Only,
[uint16]$LAG,
[string]$Description,
[ValidateSet('Access', 'Tagged', 'Tagged All', '100', '200', '300', IgnoreCase = $true)]
[string]$Mode,
[ValidateRange(1, 4094)]
[uint16]$Untagged_VLAN,
[ValidateRange(1, 4094)]
[uint16[]]$Tagged_VLANs
)
if ($null -ne $Form_Factor) {
$PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
}
if (-not [System.String]::IsNullOrWhiteSpace($Mode)) {
$PSBoundParameters.Mode = switch ($Mode) {
'Access' {
100
break
}
'Tagged' {
200
break
}
'Tagged All' {
300
break
}
default {
$_
}
}
}
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interfaces'))
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
$URI = BuildNewURI -Segments $URIComponents.Segments
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-Add-NetboxDCIMInterfaceConnection_ps1
<#
.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.
#>
2018-05-29 10:43:23 -04:00
function Add-NetboxDCIMInterfaceConnection {
<#
.SYNOPSIS
Create a new connection between two interfaces
.DESCRIPTION
Create a new connection between two interfaces
.PARAMETER Connection_Status
Is it connected or planned?
.PARAMETER Interface_A
Database ID of interface A
.PARAMETER Interface_B
Database ID of interface B
.EXAMPLE
PS C:\> Add-NetboxDCIMInterfaceConnection -Interface_A $value1 -Interface_B $value2
.NOTES
Additional information about the function.
#>
[CmdletBinding()]
[OutputType([pscustomobject])]
param
(
[object]$Connection_Status,
[Parameter(Mandatory = $true)]
[uint16]$Interface_A,
[Parameter(Mandatory = $true)]
[uint16]$Interface_B
)
if ($null -ne $Connection_Status) {
$PSBoundParameters.Connection_Status = ValidateDCIMChoice -ProvidedValue $Connection_Status -InterfaceConnectionStatus
}
# Verify if both Interfaces exist
$I_A = Get-NetboxDCIMInterface -Id $Interface_A -ErrorAction Stop
$I_B = Get-NetboxDCIMInterface -Id $Interface_B -ErrorAction Stop
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interface-connections'))
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
$URI = BuildNewURI -Segments $URIComponents.Segments
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-Set-NetboxDCIMInterface_ps1
<#
.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-NetboxDCIMInterface.ps1
===========================================================================
.DESCRIPTION
A description of the file.
#>
2018-05-29 10:43:23 -04:00
function Set-NetboxDCIMInterface {
[CmdletBinding()]
[OutputType([pscustomobject])]
param
(
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true)]
[uint16[]]$Id,
[uint16]$Device,
[string]$Name,
[bool]$Enabled,
[object]$Form_Factor,
[uint16]$MTU,
[string]$MAC_Address,
[bool]$MGMT_Only,
[uint16]$LAG,
[string]$Description,
[ValidateSet('Access', 'Tagged', 'Tagged All', '100', '200', '300', IgnoreCase = $true)]
[string]$Mode,
[ValidateRange(1, 4094)]
[uint16]$Untagged_VLAN,
[ValidateRange(1, 4094)]
[uint16[]]$Tagged_VLANs
)
begin {
if ($null -ne $Form_Factor) {
$PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
}
if (-not [System.String]::IsNullOrWhiteSpace($Mode)) {
$PSBoundParameters.Mode = switch ($Mode) {
'Access' {
100
break
}
'Tagged' {
200
break
}
'Tagged All' {
300
break
}
default {
$_
}
}
}
}
process {
foreach ($InterfaceId in $Id) {
$CurrentInterface = Get-NetboxDCIMInterface -Id $InterfaceId -ErrorAction Stop
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interfaces', $CurrentInterface.Id))
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
$URI = BuildNewURI -Segments $Segments
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
}
}
end {
}
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-Set-NetboxDCIMInterfaceConnection_ps1
<#
.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.
#>
2018-05-29 10:43:23 -04:00
function Set-NetboxDCIMInterfaceConnection {
<#
.SYNOPSIS
Update an interface connection
.DESCRIPTION
Update an interface connection
.PARAMETER Id
A description of the Id parameter.
.PARAMETER Connection_Status
A description of the Connection_Status parameter.
.PARAMETER Interface_A
A description of the Interface_A parameter.
.PARAMETER Interface_B
A description of the Interface_B parameter.
.PARAMETER Force
A description of the Force parameter.
.EXAMPLE
PS C:\> Set-NetboxDCIMInterfaceConnection -Id $value1
.NOTES
Additional information about the function.
#>
[CmdletBinding(ConfirmImpact = 'Medium',
SupportsShouldProcess = $true)]
param
(
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true)]
[uint16[]]$Id,
[object]$Connection_Status,
[uint16]$Interface_A,
[uint16]$Interface_B,
[switch]$Force
)
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)) {
throw "Cannot set multiple connections to the same interface"
}
}
process {
foreach ($ConnectionID in $Id) {
$CurrentConnection = Get-NetboxDCIMInterfaceConnection -Id $ConnectionID -ErrorAction Stop
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interface-connections', $CurrentConnection.Id))
if ($Force -or $pscmdlet.ShouldProcess("Connection ID $($CurrentConnection.Id)", "Set")) {
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
$URI = BuildNewURI -Segments $URIComponents.Segments
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
}
}
}
end {
}
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-Remove-NetboxDCIMInterface_ps1
<#
.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.
#>
2018-05-29 10:43:23 -04:00
function Remove-NetboxDCIMInterface {
<#
.SYNOPSIS
Removes an interface
.DESCRIPTION
Removes an interface by ID from a device
.PARAMETER Id
A description of the Id parameter.
.PARAMETER Force
A description of the Force parameter.
.EXAMPLE
PS C:\> Remove-NetboxDCIMInterface -Id $value1
.NOTES
Additional information about the function.
#>
[CmdletBinding(ConfirmImpact = 'High',
SupportsShouldProcess = $true)]
param
(
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true)]
[uint16[]]$Id,
[switch]$Force
)
begin {
}
process {
foreach ($InterfaceId in $Id) {
$CurrentInterface = Get-NetboxDCIMInterface -Id $InterfaceId -ErrorAction Stop
if ($Force -or $pscmdlet.ShouldProcess("Name: $($CurrentInterface.Name) | ID: $($CurrentInterface.Id)", "Remove")) {
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interfaces', $CurrentInterface.Id))
$URI = BuildNewURI -Segments $Segments
InvokeNetboxRequest -URI $URI -Method DELETE
}
}
}
end {
}
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-Remove-NetboxDCIMInterfaceConnection_ps1
<#
.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.
#>
2018-05-29 10:43:23 -04:00
function Remove-NetboxDCIMInterfaceConnection {
[CmdletBinding(ConfirmImpact = 'High',
SupportsShouldProcess = $true)]
[OutputType([void])]
param
(
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true)]
[uint16[]]$Id,
[switch]$Force
)
begin {
}
process {
foreach ($ConnectionID in $Id) {
$CurrentConnection = Get-NetboxDCIMInterfaceConnection -Id $ConnectionID -ErrorAction Stop
if ($Force -or $pscmdlet.ShouldProcess("Connection ID $($ConnectionID.Id)", "REMOVE")) {
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interface-connections', $CurrentConnection.Id))
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
$URI = BuildNewURI -Segments $URIComponents.Segments
InvokeNetboxRequest -URI $URI -Method DELETE
}
}
}
end {
}
}
2020-03-23 12:18:01 -04:00
#endregion
2018-05-11 15:54:43 -04:00
2020-03-23 12:18:01 -04:00
#region Invoke-Get-NetboxDCIMPlatform_ps1
2019-12-10 15:09:42 -05:00
<#
.NOTES
===========================================================================
2020-03-23 12:18:01 -04:00
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
Created on: 3/23/2020 12:13
Created by: Claussen
2019-12-10 15:09:42 -05:00
Organization: NEOnet
2020-03-23 12:18:01 -04:00
Filename: Get-NetboxDCIMPlatform.ps1
2019-12-10 15:09:42 -05:00
===========================================================================
.DESCRIPTION
A description of the file.
#>
2020-03-23 12:18:01 -04:00
function Get-NetboxDCIMPlatform {
2019-12-10 15:09:42 -05:00
[CmdletBinding()]
2020-03-23 12:18:01 -04:00
[OutputType([pscustomobject])]
2019-12-10 15:09:42 -05:00
param
(
[uint16]$Limit,
[uint16]$Offset,
2020-03-23 12:18:01 -04:00
[Parameter(ParameterSetName = 'ById')]
2019-12-10 15:09:42 -05:00
[uint16[]]$Id,
2020-03-23 12:18:01 -04:00
[string]$Name,
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
[string]$Slug,
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
[uint16]$Manufacturer_Id,
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
[string]$Manufacturer,
2019-12-10 15:09:42 -05:00
[switch]$Raw
)
2020-03-23 12:18:01 -04:00
switch ($PSCmdlet.ParameterSetName) {
'ById' {
foreach ($PlatformID in $Id) {
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'platforms', $PlatformID))
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Raw'
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
InvokeNetboxRequest -URI $URI -Raw:$Raw
}
break
}
default {
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'platforms'))
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
InvokeNetboxRequest -URI $URI -Raw:$Raw
}
}
}
#endregion
#region Invoke-Get-NetboxDCIMChoices_ps1
<#
.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-NetboxDCIMChoices.ps1
===========================================================================
.DESCRIPTION
A description of the file.
#>
function Get-NetboxDCIMChoices {
[CmdletBinding()]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Justification = "These are literally 'choices' in Netbox")]
param ()
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
$uriSegments = [System.Collections.ArrayList]::new(@('dcim', '_choices'))
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
$uri = BuildNewURI -Segments $uriSegments -Parameters $Parameters
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
InvokeNetboxRequest -URI $uri
2019-12-10 15:09:42 -05:00
}
2020-03-23 12:18:01 -04:00
#endregion
#region Invoke-Get-NetboxCircuitsChoices_ps1
<#
.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-NetboxCircuitsChoices.ps1
===========================================================================
.DESCRIPTION
A description of the file.
#>
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
function Get-NetboxCircuitsChoices {
2019-12-10 15:09:42 -05:00
<#
2020-03-23 12:18:01 -04:00
.SYNOPSIS
Gets the choices associated with circuits
.DESCRIPTION
A detailed description of the Get-NetboxCircuitsChoices function.
.EXAMPLE
PS C:\> Get-NetboxCircuitsChoices
.NOTES
Additional information about the function.
#>
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
[CmdletBinding()]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Justification = "These are literally 'choices' in Netbox")]
param ()
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
$uriSegments = [System.Collections.ArrayList]::new(@('circuits', '_choices'))
$uri = BuildNewURI -Segments $uriSegments
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
InvokeNetboxRequest -URI $uri
}
#endregion
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
#region Invoke-Get-NetboxCircuit_ps1
<#
.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 {
2019-12-10 15:09:42 -05:00
<#
2020-03-23 12:18:01 -04:00
.SYNOPSIS
Gets one or more circuits
.DESCRIPTION
A detailed description of the Get-NetboxCircuit function.
.PARAMETER CID
Circuit ID
.PARAMETER InstallDate
Date of installation
.PARAMETER CommitRate
Committed rate in Kbps
.PARAMETER Query
A raw search query... As if you were searching the web site
.PARAMETER Provider
The name or ID of the provider. Provide either [string] or [int]. String will search provider names, integer will search database IDs
.PARAMETER Type
Type of circuit. Provide either [string] or [int]. String will search provider type names, integer will search database IDs
.PARAMETER Site
Location/site of circuit. Provide either [string] or [int]. String will search site names, integer will search database IDs
.PARAMETER Tenant
Tenant assigned to circuit. Provide either [string] or [int]. String will search tenant names, integer will search database IDs
.PARAMETER Id
Database ID of circuit. This will query for exactly the IDs provided
.PARAMETER ID__IN
Multiple unique DB IDs to retrieve
.EXAMPLE
PS C:\> Get-NetboxCircuit
.NOTES
Additional information about the function.
2019-12-10 15:09:42 -05:00
#>
2020-03-23 12:18:01 -04:00
[CmdletBinding()]
2019-12-10 15:09:42 -05:00
param
(
2020-03-23 12:18:01 -04:00
[string]$CID,
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
[datetime]$InstallDate,
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
[uint32]$CommitRate,
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
[string]$Query,
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
[object]$Provider,
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
[object]$Type,
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
[string]$Site,
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
[string]$Tenant,
2019-12-10 15:09:42 -05:00
2020-03-23 12:18:01 -04:00
[uint16[]]$Id
2019-12-10 15:09:42 -05:00
)
2020-03-23 12:18:01 -04:00
#TODO: Place script here
2019-12-10 15:09:42 -05:00
}
2020-03-23 12:18:01 -04:00
#endregion
2019-12-10 15:09:42 -05:00
# Build a list of common paramters so we can omit them to build URI parameters
$script:CommonParameterNames = New-Object System.Collections.ArrayList
[void]$script:CommonParameterNames.AddRange(@([System.Management.Automation.PSCmdlet]::CommonParameters))
[void]$script:CommonParameterNames.AddRange(@([System.Management.Automation.PSCmdlet]::OptionalCommonParameters))
[void]$script:CommonParameterNames.Add('Raw')
SetupNetboxConfigVariable
Export-ModuleMember -Function *
#Export-ModuleMember -Function *-*