mirror of
https://github.com/benclaussen/NetboxPS.git
synced 2025-12-12 17:32:29 +00:00
File restructuring
This commit is contained in:
parent
9f543b8f2d
commit
d6b4e69f69
25 changed files with 762 additions and 4289 deletions
|
|
@ -1,24 +0,0 @@
|
|||
<#
|
||||
.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 {
|
||||
[CmdletBinding()]
|
||||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Justification = "These are literally 'choices' in Netbox")]
|
||||
param ()
|
||||
|
||||
$uriSegments = [System.Collections.ArrayList]::new(@('extras', '_choices'))
|
||||
|
||||
$uri = BuildNewURI -Segments $uriSegments
|
||||
|
||||
InvokeNetboxRequest -URI $uri
|
||||
}
|
||||
11
Functions/Extras/Get-NetboxExtrasChoices.ps1
Normal file
11
Functions/Extras/Get-NetboxExtrasChoices.ps1
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
function Get-NetboxExtrasChoices {
|
||||
[CmdletBinding()]
|
||||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Justification = "These are literally 'choices' in Netbox")]
|
||||
param ()
|
||||
|
||||
$uriSegments = [System.Collections.ArrayList]::new(@('extras', '_choices'))
|
||||
|
||||
$uri = BuildNewURI -Segments $uriSegments
|
||||
|
||||
InvokeNetboxRequest -URI $uri
|
||||
}
|
||||
|
|
@ -1,445 +0,0 @@
|
|||
<#
|
||||
.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: Helpers.ps1
|
||||
===========================================================================
|
||||
.DESCRIPTION
|
||||
These function are internal functions and generally are not
|
||||
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
|
||||
Internal function used to build a URIBuilder object.
|
||||
|
||||
.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) {
|
||||
Write-Verbose " Setting scheme to HTTPS"
|
||||
$Scheme = 'https'
|
||||
} else {
|
||||
Write-Warning " Connecting via non-secure HTTP is not-recommended"
|
||||
|
||||
Write-Verbose " Setting scheme to HTTP"
|
||||
$Scheme = 'http'
|
||||
|
||||
if (-not $PSBoundParameters.ContainsKey('Port')) {
|
||||
# Set the port to 80 if the user did not supply it
|
||||
Write-Verbose " Setting port to 80 as default because it was not supplied by the user"
|
||||
$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 '/')
|
||||
|
||||
Write-Verbose " URIPath: $($uriBuilder.Path)"
|
||||
|
||||
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()) {
|
||||
Write-Verbose " Adding URI parameter $($param.Key):$($param.Value)"
|
||||
$URIParams[$param.Key] = $param.Value
|
||||
}
|
||||
|
||||
$uriBuilder.Query = $URIParams.ToString()
|
||||
}
|
||||
|
||||
Write-Verbose " Completed building URIBuilder"
|
||||
# Return the entire UriBuilder object
|
||||
$uriBuilder
|
||||
}
|
||||
|
||||
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"
|
||||
|
||||
$URIParameters = @{}
|
||||
|
||||
foreach ($CmdletParameterName in $ParametersDictionary.Keys) {
|
||||
if ($CmdletParameterName -in $script:CommonParameterNames) {
|
||||
# These are common parameters and should not be appended to the URI
|
||||
Write-Debug "Skipping common parameter $CmdletParameterName"
|
||||
continue
|
||||
}
|
||||
|
||||
if ($CmdletParameterName -in $SkipParameterByName) {
|
||||
Write-Debug "Skipping parameter $CmdletParameterName by SkipParameterByName"
|
||||
continue
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return @{
|
||||
'Segments' = [System.Collections.ArrayList]$URISegments
|
||||
'Parameters' = $URIParameters
|
||||
}
|
||||
}
|
||||
|
||||
function GetChoiceValidValues {
|
||||
[CmdletBinding()]
|
||||
[OutputType([System.Collections.ArrayList])]
|
||||
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()]
|
||||
[OutputType([uint16], [string], [bool])]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateSet('Circuits', 'DCIM', 'Extras', 'IPAM', 'Virtualization', IgnoreCase = $true)]
|
||||
[string]$MajorObject,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$ChoiceName,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[object]$ProvidedValue
|
||||
)
|
||||
|
||||
$ValidValues = GetChoiceValidValues -MajorObject $MajorObject -Choice $ChoiceName
|
||||
|
||||
Write-Verbose "Validating $ChoiceName"
|
||||
Write-Verbose "Checking '$ProvidedValue' against [$($ValidValues -join ', ')]"
|
||||
|
||||
# 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) {
|
||||
throw "Invalid value '$ProvidedValue' for '$ChoiceName'. Must be one of: $($ValidValues -join ', ')"
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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 {
|
||||
[CmdletBinding()]
|
||||
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
|
||||
)
|
||||
|
||||
$creds = Get-NetboxCredential
|
||||
|
||||
$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) {
|
||||
Write-Verbose "Returning raw result by choice"
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#region Troubleshooting commands
|
||||
|
||||
function ThrowNetboxRESTError {
|
||||
$uriSegments = [System.Collections.ArrayList]::new(@('fake', 'url'))
|
||||
|
||||
$URIParameters = @{}
|
||||
|
||||
$uri = BuildNewURI -Segments $uriSegments -Parameters $URIParameters
|
||||
|
||||
InvokeNetboxRequest -URI $uri -Raw
|
||||
}
|
||||
|
||||
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."
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Troubleshooting commands
|
||||
|
||||
|
||||
|
||||
122
Functions/Helpers/BuildNewURI.ps1
Normal file
122
Functions/Helpers/BuildNewURI.ps1
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
<#
|
||||
.NOTES
|
||||
===========================================================================
|
||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||
Created on: 3/26/2020 14:22
|
||||
Created by: Claussen
|
||||
Organization: NEOnet
|
||||
Filename: BuildNewURI.ps1
|
||||
===========================================================================
|
||||
.DESCRIPTION
|
||||
A description of the file.
|
||||
#>
|
||||
|
||||
|
||||
function BuildNewURI {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Create a new URI for Netbox
|
||||
|
||||
.DESCRIPTION
|
||||
Internal function used to build a URIBuilder object.
|
||||
|
||||
.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) {
|
||||
Write-Verbose " Setting scheme to HTTPS"
|
||||
$Scheme = 'https'
|
||||
} else {
|
||||
Write-Warning " Connecting via non-secure HTTP is not-recommended"
|
||||
|
||||
Write-Verbose " Setting scheme to HTTP"
|
||||
$Scheme = 'http'
|
||||
|
||||
if (-not $PSBoundParameters.ContainsKey('Port')) {
|
||||
# Set the port to 80 if the user did not supply it
|
||||
Write-Verbose " Setting port to 80 as default because it was not supplied by the user"
|
||||
$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 '/')
|
||||
|
||||
Write-Verbose " URIPath: $($uriBuilder.Path)"
|
||||
|
||||
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()) {
|
||||
Write-Verbose " Adding URI parameter $($param.Key):$($param.Value)"
|
||||
$URIParams[$param.Key] = $param.Value
|
||||
}
|
||||
|
||||
$uriBuilder.Query = $URIParams.ToString()
|
||||
}
|
||||
|
||||
Write-Verbose " Completed building URIBuilder"
|
||||
# Return the entire UriBuilder object
|
||||
$uriBuilder
|
||||
}
|
||||
88
Functions/Helpers/BuildURIComponents.ps1
Normal file
88
Functions/Helpers/BuildURIComponents.ps1
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
<#
|
||||
.NOTES
|
||||
===========================================================================
|
||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||
Created on: 3/26/2020 14:23
|
||||
Created by: Claussen
|
||||
Organization: NEOnet
|
||||
Filename: BuildURIComponents.ps1
|
||||
===========================================================================
|
||||
.DESCRIPTION
|
||||
A description of the file.
|
||||
#>
|
||||
|
||||
|
||||
function BuildURIComponents {
|
||||
[CmdletBinding()]
|
||||
[OutputType([hashtable])]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[System.Collections.ArrayList]$URISegments,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[object]$ParametersDictionary,
|
||||
|
||||
[string[]]$SkipParameterByName
|
||||
)
|
||||
|
||||
Write-Verbose "Building URI components"
|
||||
|
||||
$URIParameters = @{
|
||||
}
|
||||
|
||||
foreach ($CmdletParameterName in $ParametersDictionary.Keys) {
|
||||
if ($CmdletParameterName -in $script:CommonParameterNames) {
|
||||
# These are common parameters and should not be appended to the URI
|
||||
Write-Debug "Skipping common parameter $CmdletParameterName"
|
||||
continue
|
||||
}
|
||||
|
||||
if ($CmdletParameterName -in $SkipParameterByName) {
|
||||
Write-Debug "Skipping parameter $CmdletParameterName by SkipParameterByName"
|
||||
continue
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return @{
|
||||
'Segments' = [System.Collections.ArrayList]$URISegments
|
||||
'Parameters' = $URIParameters
|
||||
}
|
||||
}
|
||||
23
Functions/Helpers/CheckNetboxIsConnected.ps1
Normal file
23
Functions/Helpers/CheckNetboxIsConnected.ps1
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<#
|
||||
.NOTES
|
||||
===========================================================================
|
||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||
Created on: 3/26/2020 14:22
|
||||
Created by: Claussen
|
||||
Organization: NEOnet
|
||||
Filename: CheckNetboxIsConnected.ps1
|
||||
===========================================================================
|
||||
.DESCRIPTION
|
||||
A description of the file.
|
||||
#>
|
||||
|
||||
|
||||
function CheckNetboxIsConnected {
|
||||
[CmdletBinding()]
|
||||
param ()
|
||||
|
||||
Write-Verbose "Checking connection status"
|
||||
if (-not $script:NetboxConfig.Connected) {
|
||||
throw "Not connected to a Netbox API! Please run 'Connect-NetboxAPI'"
|
||||
}
|
||||
}
|
||||
41
Functions/Helpers/CreateEnum.ps1
Normal file
41
Functions/Helpers/CreateEnum.ps1
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<#
|
||||
.NOTES
|
||||
===========================================================================
|
||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||
Created on: 3/26/2020 14:25
|
||||
Created by: Claussen
|
||||
Organization: NEOnet
|
||||
Filename: CreateEnum.ps1
|
||||
===========================================================================
|
||||
.DESCRIPTION
|
||||
A description of the file.
|
||||
#>
|
||||
|
||||
|
||||
function CreateEnum {
|
||||
[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."
|
||||
}
|
||||
}
|
||||
41
Functions/Helpers/GetChoiceValidValues.ps1
Normal file
41
Functions/Helpers/GetChoiceValidValues.ps1
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<#
|
||||
.NOTES
|
||||
===========================================================================
|
||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||
Created on: 3/26/2020 14:23
|
||||
Created by: Claussen
|
||||
Organization: NEOnet
|
||||
Filename: GetChoiceValidValues.ps1
|
||||
===========================================================================
|
||||
.DESCRIPTION
|
||||
A description of the file.
|
||||
#>
|
||||
|
||||
|
||||
function GetChoiceValidValues {
|
||||
[CmdletBinding()]
|
||||
[OutputType([System.Collections.ArrayList])]
|
||||
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
|
||||
}
|
||||
29
Functions/Helpers/GetNetboxAPIErrorBody.ps1
Normal file
29
Functions/Helpers/GetNetboxAPIErrorBody.ps1
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<#
|
||||
.NOTES
|
||||
===========================================================================
|
||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||
Created on: 3/26/2020 14:23
|
||||
Created by: Claussen
|
||||
Organization: NEOnet
|
||||
Filename: GetNetboxAPIErrorBody.ps1
|
||||
===========================================================================
|
||||
.DESCRIPTION
|
||||
A description of the file.
|
||||
#>
|
||||
|
||||
|
||||
function GetNetboxAPIErrorBody {
|
||||
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()
|
||||
}
|
||||
105
Functions/Helpers/InvokeNetboxRequest.ps1
Normal file
105
Functions/Helpers/InvokeNetboxRequest.ps1
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
<#
|
||||
.NOTES
|
||||
===========================================================================
|
||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||
Created on: 3/26/2020 14:24
|
||||
Created by: Claussen
|
||||
Organization: NEOnet
|
||||
Filename: InvokeNetboxRequest.ps1
|
||||
===========================================================================
|
||||
.DESCRIPTION
|
||||
A description of the file.
|
||||
#>
|
||||
|
||||
|
||||
function InvokeNetboxRequest {
|
||||
[CmdletBinding()]
|
||||
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
|
||||
)
|
||||
|
||||
$creds = Get-NetboxCredential
|
||||
|
||||
$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) {
|
||||
Write-Verbose "Returning raw result by choice"
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
24
Functions/Helpers/ThrowNetboxRESTError.ps1
Normal file
24
Functions/Helpers/ThrowNetboxRESTError.ps1
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<#
|
||||
.NOTES
|
||||
===========================================================================
|
||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||
Created on: 3/26/2020 14:25
|
||||
Created by: Claussen
|
||||
Organization: NEOnet
|
||||
Filename: ThrowNetboxRESTError.ps1
|
||||
===========================================================================
|
||||
.DESCRIPTION
|
||||
A description of the file.
|
||||
#>
|
||||
|
||||
|
||||
function ThrowNetboxRESTError {
|
||||
$uriSegments = [System.Collections.ArrayList]::new(@('fake', 'url'))
|
||||
|
||||
$URIParameters = @{
|
||||
}
|
||||
|
||||
$uri = BuildNewURI -Segments $uriSegments -Parameters $URIParameters
|
||||
|
||||
InvokeNetboxRequest -URI $uri -Raw
|
||||
}
|
||||
76
Functions/Helpers/ValidateChoice.ps1
Normal file
76
Functions/Helpers/ValidateChoice.ps1
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
<#
|
||||
.NOTES
|
||||
===========================================================================
|
||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||
Created on: 3/26/2020 14:23
|
||||
Created by: Claussen
|
||||
Organization: NEOnet
|
||||
Filename: ValidateChoice.ps1
|
||||
===========================================================================
|
||||
.DESCRIPTION
|
||||
A description of the file.
|
||||
#>
|
||||
|
||||
|
||||
function ValidateChoice {
|
||||
[CmdletBinding()]
|
||||
[OutputType([uint16], [string], [bool])]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateSet('Circuits', 'DCIM', 'Extras', 'IPAM', 'Virtualization', IgnoreCase = $true)]
|
||||
[string]$MajorObject,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$ChoiceName,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[object]$ProvidedValue
|
||||
)
|
||||
|
||||
$ValidValues = GetChoiceValidValues -MajorObject $MajorObject -Choice $ChoiceName
|
||||
|
||||
Write-Verbose "Validating $ChoiceName"
|
||||
Write-Verbose "Checking '$ProvidedValue' against [$($ValidValues -join ', ')]"
|
||||
|
||||
# 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) {
|
||||
throw "Invalid value '$ProvidedValue' for '$ChoiceName'. Must be one of: $($ValidValues -join ', ')"
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,169 +0,0 @@
|
|||
<#
|
||||
.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 {
|
||||
[CmdletBinding(ConfirmImpact = 'Low',
|
||||
SupportsShouldProcess = $true)]
|
||||
[OutputType([string])]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Hostname
|
||||
)
|
||||
|
||||
if ($PSCmdlet.ShouldProcess('Netbox Hostname', 'Set')) {
|
||||
$script:NetboxConfig.Hostname = $Hostname.Trim()
|
||||
$script:NetboxConfig.Hostname
|
||||
}
|
||||
}
|
||||
|
||||
function Get-NetboxHostname {
|
||||
[CmdletBinding()]
|
||||
param ()
|
||||
|
||||
Write-Verbose "Getting Netbox hostname"
|
||||
if ($null -eq $script:NetboxConfig.Hostname) {
|
||||
throw "Netbox Hostname is not set! You may set it with Set-NetboxHostname -Hostname 'hostname.domain.tld'"
|
||||
}
|
||||
|
||||
$script:NetboxConfig.Hostname
|
||||
}
|
||||
|
||||
function Set-NetboxCredential {
|
||||
[CmdletBinding(DefaultParameterSetName = 'CredsObject',
|
||||
ConfirmImpact = 'Low',
|
||||
SupportsShouldProcess = $true)]
|
||||
[OutputType([pscredential])]
|
||||
param
|
||||
(
|
||||
[Parameter(ParameterSetName = 'CredsObject',
|
||||
Mandatory = $true)]
|
||||
[pscredential]$Credential,
|
||||
|
||||
[Parameter(ParameterSetName = 'UserPass',
|
||||
Mandatory = $true)]
|
||||
[securestring]$Token
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
$script:NetboxConfig.Credential
|
||||
}
|
||||
}
|
||||
|
||||
function Get-NetboxCredential {
|
||||
[CmdletBinding()]
|
||||
[OutputType([pscredential])]
|
||||
param ()
|
||||
|
||||
if (-not $script:NetboxConfig.Credential) {
|
||||
throw "Netbox Credentials not set! You may set with Set-NetboxCredential"
|
||||
}
|
||||
|
||||
$script:NetboxConfig.Credential
|
||||
}
|
||||
|
||||
function Connect-NetboxAPI {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Connects to the Netbox API and ensures Credential work properly
|
||||
|
||||
.DESCRIPTION
|
||||
A detailed description of the Connect-NetboxAPI function.
|
||||
|
||||
.PARAMETER Hostname
|
||||
A description of the Hostname parameter.
|
||||
|
||||
.PARAMETER Credential
|
||||
A description of the Credential parameter.
|
||||
|
||||
.EXAMPLE
|
||||
PS C:\> Connect-NetboxAPI -Hostname "netbox.domain.com"
|
||||
|
||||
This will prompt for Credential, then proceed to attempt a connection to Netbox
|
||||
|
||||
.NOTES
|
||||
Additional information about the function.
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Hostname,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[pscredential]$Credential
|
||||
)
|
||||
|
||||
if (-not $Credential) {
|
||||
try {
|
||||
$Credential = Get-NetboxCredential -ErrorAction Stop
|
||||
} catch {
|
||||
# Credentials are not set... Try to obtain from the user
|
||||
if (-not ($Credential = Get-Credential -UserName 'username-not-applicable' -Message "Enter token for Netbox")) {
|
||||
throw "Token is necessary to connect to a Netbox API."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$null = Set-NetboxHostName -Hostname $Hostname
|
||||
$null = Set-NetboxCredential -Credential $Credential
|
||||
|
||||
try {
|
||||
Write-Verbose "Verifying API connectivity..."
|
||||
$null = VerifyAPIConnectivity
|
||||
$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 $_
|
||||
}
|
||||
}
|
||||
|
||||
Write-Verbose "Caching static choices"
|
||||
$script:NetboxConfig.Choices.Circuits = Get-NetboxCircuitsChoices
|
||||
$script:NetboxConfig.Choices.DCIM = Get-NetboxDCIMChoices # Not completed yet
|
||||
$script:NetboxConfig.Choices.Extras = Get-NetboxExtrasChoices
|
||||
$script:NetboxConfig.Choices.IPAM = Get-NetboxIPAMChoices
|
||||
#$script:NetboxConfig.Choices.Secrets = Get-NetboxSecretsChoices # Not completed yet
|
||||
#$script:NetboxConfig.Choices.Tenancy = Get-NetboxTenancyChoices
|
||||
$script:NetboxConfig.Choices.Virtualization = Get-NetboxVirtualizationChoices
|
||||
|
||||
Write-Verbose "Connection process completed"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
73
Functions/Setup/Connect-NetboxAPI.ps1
Normal file
73
Functions/Setup/Connect-NetboxAPI.ps1
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
function Connect-NetboxAPI {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Connects to the Netbox API and ensures Credential work properly
|
||||
|
||||
.DESCRIPTION
|
||||
A detailed description of the Connect-NetboxAPI function.
|
||||
|
||||
.PARAMETER Hostname
|
||||
A description of the Hostname parameter.
|
||||
|
||||
.PARAMETER Credential
|
||||
A description of the Credential parameter.
|
||||
|
||||
.EXAMPLE
|
||||
PS C:\> Connect-NetboxAPI -Hostname "netbox.domain.com"
|
||||
|
||||
This will prompt for Credential, then proceed to attempt a connection to Netbox
|
||||
|
||||
.NOTES
|
||||
Additional information about the function.
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Hostname,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[pscredential]$Credential
|
||||
)
|
||||
|
||||
if (-not $Credential) {
|
||||
try {
|
||||
$Credential = Get-NetboxCredential -ErrorAction Stop
|
||||
} catch {
|
||||
# Credentials are not set... Try to obtain from the user
|
||||
if (-not ($Credential = Get-Credential -UserName 'username-not-applicable' -Message "Enter token for Netbox")) {
|
||||
throw "Token is necessary to connect to a Netbox API."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$null = Set-NetboxHostName -Hostname $Hostname
|
||||
$null = Set-NetboxCredential -Credential $Credential
|
||||
|
||||
try {
|
||||
Write-Verbose "Verifying API connectivity..."
|
||||
$null = VerifyAPIConnectivity
|
||||
$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 $_
|
||||
}
|
||||
}
|
||||
|
||||
Write-Verbose "Caching static choices"
|
||||
$script:NetboxConfig.Choices.Circuits = Get-NetboxCircuitsChoices
|
||||
$script:NetboxConfig.Choices.DCIM = Get-NetboxDCIMChoices # Not completed yet
|
||||
$script:NetboxConfig.Choices.Extras = Get-NetboxExtrasChoices
|
||||
$script:NetboxConfig.Choices.IPAM = Get-NetboxIPAMChoices
|
||||
#$script:NetboxConfig.Choices.Secrets = Get-NetboxSecretsChoices # Not completed yet
|
||||
#$script:NetboxConfig.Choices.Tenancy = Get-NetboxTenancyChoices
|
||||
$script:NetboxConfig.Choices.Virtualization = Get-NetboxVirtualizationChoices
|
||||
|
||||
Write-Verbose "Connection process completed"
|
||||
}
|
||||
11
Functions/Setup/Get-NetboxCredential.ps1
Normal file
11
Functions/Setup/Get-NetboxCredential.ps1
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
function Get-NetboxCredential {
|
||||
[CmdletBinding()]
|
||||
[OutputType([pscredential])]
|
||||
param ()
|
||||
|
||||
if (-not $script:NetboxConfig.Credential) {
|
||||
throw "Netbox Credentials not set! You may set with Set-NetboxCredential"
|
||||
}
|
||||
|
||||
$script:NetboxConfig.Credential
|
||||
}
|
||||
11
Functions/Setup/Get-NetboxHostname.ps1
Normal file
11
Functions/Setup/Get-NetboxHostname.ps1
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
function Get-NetboxHostname {
|
||||
[CmdletBinding()]
|
||||
param ()
|
||||
|
||||
Write-Verbose "Getting Netbox hostname"
|
||||
if ($null -eq $script:NetboxConfig.Hostname) {
|
||||
throw "Netbox Hostname is not set! You may set it with Set-NetboxHostname -Hostname 'hostname.domain.tld'"
|
||||
}
|
||||
|
||||
$script:NetboxConfig.Hostname
|
||||
}
|
||||
32
Functions/Setup/Set-NetboxCredential.ps1
Normal file
32
Functions/Setup/Set-NetboxCredential.ps1
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
function Set-NetboxCredential {
|
||||
[CmdletBinding(DefaultParameterSetName = 'CredsObject',
|
||||
ConfirmImpact = 'Low',
|
||||
SupportsShouldProcess = $true)]
|
||||
[OutputType([pscredential])]
|
||||
param
|
||||
(
|
||||
[Parameter(ParameterSetName = 'CredsObject',
|
||||
Mandatory = $true)]
|
||||
[pscredential]$Credential,
|
||||
|
||||
[Parameter(ParameterSetName = 'UserPass',
|
||||
Mandatory = $true)]
|
||||
[securestring]$Token
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
$script:NetboxConfig.Credential
|
||||
}
|
||||
}
|
||||
15
Functions/Setup/Set-NetboxHostName.ps1
Normal file
15
Functions/Setup/Set-NetboxHostName.ps1
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
function Set-NetboxHostName {
|
||||
[CmdletBinding(ConfirmImpact = 'Low',
|
||||
SupportsShouldProcess = $true)]
|
||||
[OutputType([string])]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Hostname
|
||||
)
|
||||
|
||||
if ($PSCmdlet.ShouldProcess('Netbox Hostname', 'Set')) {
|
||||
$script:NetboxConfig.Hostname = $Hostname.Trim()
|
||||
$script:NetboxConfig.Hostname
|
||||
}
|
||||
}
|
||||
3
Functions/Setup/Support/GetNetboxConfigVariable.ps1
Normal file
3
Functions/Setup/Support/GetNetboxConfigVariable.ps1
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
function GetNetboxConfigVariable {
|
||||
return $script:NetboxConfig
|
||||
}
|
||||
|
|
@ -1,15 +1,4 @@
|
|||
function VerifyAPIConnectivity {
|
||||
[CmdletBinding()]
|
||||
param ()
|
||||
|
||||
$uriSegments = [System.Collections.ArrayList]::new(@('extras', '_choices'))
|
||||
|
||||
$uri = BuildNewURI -Segments $uriSegments -SkipConnectedCheck
|
||||
|
||||
InvokeNetboxRequest -URI $uri
|
||||
}
|
||||
|
||||
function SetupNetboxConfigVariable {
|
||||
function SetupNetboxConfigVariable {
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
|
|
@ -21,14 +10,10 @@ function SetupNetboxConfigVariable {
|
|||
Write-Verbose "Creating NetboxConfig hashtable"
|
||||
$script:NetboxConfig = @{
|
||||
'Connected' = $false
|
||||
'Choices' = @{
|
||||
'Choices' = @{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write-Verbose "NetboxConfig hashtable already exists"
|
||||
}
|
||||
|
||||
function GetNetboxConfigVariable {
|
||||
return $script:NetboxConfig
|
||||
}
|
||||
10
Functions/Setup/Support/VerifyAPIConnectivity.ps1
Normal file
10
Functions/Setup/Support/VerifyAPIConnectivity.ps1
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
function VerifyAPIConnectivity {
|
||||
[CmdletBinding()]
|
||||
param ()
|
||||
|
||||
$uriSegments = [System.Collections.ArrayList]::new(@('extras', '_choices'))
|
||||
|
||||
$uri = BuildNewURI -Segments $uriSegments -SkipConnectedCheck
|
||||
|
||||
InvokeNetboxRequest -URI $uri
|
||||
}
|
||||
|
|
@ -99,10 +99,6 @@ function Get-NetboxVirtualMachine {
|
|||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
[uint16]$Limit,
|
||||
|
||||
[uint16]$Offset,
|
||||
|
||||
[Alias('q')]
|
||||
[string]$Query,
|
||||
|
||||
|
|
@ -138,6 +134,10 @@ function Get-NetboxVirtualMachine {
|
|||
|
||||
[uint16]$Role_Id,
|
||||
|
||||
[uint16]$Limit,
|
||||
|
||||
[uint16]$Offset,
|
||||
|
||||
[switch]$Raw
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@
|
|||
NestedModules = @()
|
||||
|
||||
# Functions to export from this module
|
||||
FunctionsToExport = '*' #For performanace, list functions explicity
|
||||
FunctionsToExport = @('*') #For performanace, list functions explicity
|
||||
|
||||
# Cmdlets to export from this module
|
||||
CmdletsToExport = '*'
|
||||
|
|
|
|||
3625
NetboxPS.psm1
3625
NetboxPS.psm1
File diff suppressed because it is too large
Load diff
|
|
@ -1,4 +1,4 @@
|
|||
<Project Synchronized="False" SyncFilter="*.ps1;*.psm1;*.psd1;*.ps1xml;*.psf;*.pss;*.xml;*.help.txt" AutoExportFunctions="False" AutoExportPS1XMLFiles="False">
|
||||
<Project Synchronized="False" SyncFilter="*.ps1;*.psm1;*.psd1;*.ps1xml;*.psf;*.pss;*.xml;*.help.txt" AutoExportFunctions="True" AutoExportPS1XMLFiles="False">
|
||||
<Version>2.1</Version>
|
||||
<FileID>bba9b06c-49c8-47cf-8358-aca7c4e78896</FileID>
|
||||
<ProjectType>1</ProjectType>
|
||||
|
|
@ -7,7 +7,6 @@
|
|||
<Folder>Functions\DCIM</Folder>
|
||||
<Folder>Functions\Extras</Folder>
|
||||
<Folder>Functions\Circuits</Folder>
|
||||
<Folder>Tests</Folder>
|
||||
<Folder>Functions\Virtualization</Folder>
|
||||
<Folder>Functions\IPAM</Folder>
|
||||
<Folder>Functions\Tenancy</Folder>
|
||||
|
|
@ -21,15 +20,16 @@
|
|||
<Folder>Functions\Virtualization\VirtualizationCluster</Folder>
|
||||
<Folder>Functions\DCIM\Devices</Folder>
|
||||
<Folder>Functions\DCIM\Interfaces</Folder>
|
||||
<Folder>Functions\Helpers</Folder>
|
||||
<Folder>Functions\Setup</Folder>
|
||||
<Folder>Functions\Setup\Support</Folder>
|
||||
<Folder>Tests</Folder>
|
||||
</Folders>
|
||||
<Files>
|
||||
<File Build="2">NetboxPS.psd1</File>
|
||||
<File Build="0" ExportFunctions="False">NetboxPS.psm1</File>
|
||||
<File Build="1" Shared="False" ReferenceFunction="Invoke-Test-Module_ps1" ExportFunctions="False">Test-Module.ps1</File>
|
||||
<File Build="0" ExportFunctions="True">NetboxPS.psm1</File>
|
||||
<File Build="1">.gitignore</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Helpers_ps1" ExportFunctions="False">Functions\Helpers.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Setup_ps1" ExportFunctions="False">Functions\Setup.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Extras_ps1" ExportFunctions="True">Functions\Extras\Extras.ps1</File>
|
||||
<File Build="1" Shared="False" ReferenceFunction="Invoke-Test-Module_ps1" ExportFunctions="False">Test-Module.ps1</File>
|
||||
<File Build="1" Shared="False" ReferenceFunction="Invoke-Setup_Tests_ps1" ExportFunctions="False">Tests\Setup.Tests.ps1</File>
|
||||
<File Build="2" Shared="True" ReferenceFunction="Invoke-Helpers_Tests_ps1" ExportFunctions="False">Tests\Helpers.Tests.ps1</File>
|
||||
<File Build="2" Shared="True" ReferenceFunction="Invoke-Virtualization_Tests_ps1" ExportFunctions="False">Tests\Virtualization.Tests.ps1</File>
|
||||
|
|
@ -39,33 +39,50 @@
|
|||
<File Build="2" Shared="True" ReferenceFunction="Invoke-DCIM_Devices_Tests_ps1" ExportFunctions="False">Tests\DCIM.Devices.Tests.ps1</File>
|
||||
<File Build="2" Shared="True" ReferenceFunction="Invoke-DCIM_Interfaces_Tests_ps1" ExportFunctions="False">Tests\DCIM.Interfaces.Tests.ps1</File>
|
||||
<File Build="2" Shared="True" ReferenceFunction="Invoke-DCIM_Platforms_Tests_ps1" ExportFunctions="False">Tests\DCIM.Platforms.Tests.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-CheckNetboxIsConnected_ps1" ExportFunctions="True">Functions\Helpers\CheckNetboxIsConnected.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-BuildNewURI_ps1" ExportFunctions="True">Functions\Helpers\BuildNewURI.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-BuildURIComponents_ps1" ExportFunctions="True">Functions\Helpers\BuildURIComponents.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-GetChoiceValidValues_ps1" ExportFunctions="True">Functions\Helpers\GetChoiceValidValues.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-ValidateChoice_ps1" ExportFunctions="True">Functions\Helpers\ValidateChoice.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-GetNetboxAPIErrorBody_ps1" ExportFunctions="True">Functions\Helpers\GetNetboxAPIErrorBody.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-InvokeNetboxRequest_ps1" ExportFunctions="True">Functions\Helpers\InvokeNetboxRequest.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-ThrowNetboxRESTError_ps1" ExportFunctions="True">Functions\Helpers\ThrowNetboxRESTError.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-CreateEnum_ps1" ExportFunctions="True">Functions\Helpers\CreateEnum.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-VerifyAPIConnectivity_ps1" ExportFunctions="True">Functions\Setup\Support\VerifyAPIConnectivity.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-SetupNetboxConfigVariable_ps1" ExportFunctions="True">Functions\Setup\Support\SetupNetboxConfigVariable.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-GetNetboxConfigVariable_ps1" ExportFunctions="True">Functions\Setup\Support\GetNetboxConfigVariable.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Set-NetboxHostName_ps1" ExportFunctions="True">Functions\Setup\Set-NetboxHostName.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxHostname_ps1" ExportFunctions="True">Functions\Setup\Get-NetboxHostname.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Set-NetboxCredential_ps1" ExportFunctions="True">Functions\Setup\Set-NetboxCredential.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxCredential_ps1" ExportFunctions="True">Functions\Setup\Get-NetboxCredential.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Connect-NetboxAPI_ps1" ExportFunctions="True">Functions\Setup\Connect-NetboxAPI.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxExtrasChoices_ps1" ExportFunctions="True">Functions\Extras\Get-NetboxExtrasChoices.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-ValidateDCIMChoice_ps1" ExportFunctions="False">Functions\DCIM\ValidateDCIMChoice.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Setup_Support_ps1" ExportFunctions="False">Functions\Setup.Support.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxIPAMVLAN_ps1" ExportFunctions="True">Functions\IPAM\VLAN\Get-NetboxIPAMVLAN.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-New-NetboxIPAMVLAN_ps1" ExportFunctions="True">Functions\IPAM\VLAN\New-NetboxIPAMVLAN.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxIPAMRole_ps1" ExportFunctions="True">Functions\IPAM\Role\Get-NetboxIPAMRole.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxIPAMAggregate_ps1" ExportFunctions="True">Functions\IPAM\Aggregate\Get-NetboxIPAMAggregate.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxIPAMAddress_ps1" ExportFunctions="True">Functions\IPAM\Address\Get-NetboxIPAMAddress.ps1</File>
|
||||
<File Build="2" Shared="True" ReferenceFunction="Invoke-Get-NetboxIPAMAvailableIP_ps1" ExportFunctions="False">Functions\IPAM\Address\Get-NetboxIPAMAvailableIP.ps1</File>
|
||||
<File Build="2" Shared="True" ReferenceFunction="Invoke-Get-NetboxIPAMPrefix_ps1" ExportFunctions="False">Functions\IPAM\Prefix\Get-NetboxIPAMPrefix.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxIPAMAvailableIP_ps1" ExportFunctions="True">Functions\IPAM\Address\Get-NetboxIPAMAvailableIP.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxIPAMPrefix_ps1" ExportFunctions="True">Functions\IPAM\Prefix\Get-NetboxIPAMPrefix.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-New-NetboxIPAMAddress_ps1" ExportFunctions="True">Functions\IPAM\Address\New-NetboxIPAMAddress.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-New-NetboxIPAMPrefix_ps1" ExportFunctions="True">Functions\IPAM\Prefix\New-NetboxIPAMPrefix.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Remove-NetboxIPAMAddress_ps1" ExportFunctions="True">Functions\IPAM\Address\Remove-NetboxIPAMAddress.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Set-NetboxIPAMAddress_ps1" ExportFunctions="True">Functions\IPAM\Address\Set-NetboxIPAMAddress.ps1</File>
|
||||
<File Build="2" Shared="True" ReferenceFunction="Invoke-ValidateIPAMChoice_ps1" ExportFunctions="False">Functions\IPAM\ValidateIPAMChoice.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-ValidateIPAMChoice_ps1" ExportFunctions="True">Functions\IPAM\ValidateIPAMChoice.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxIPAMChoices_ps1" ExportFunctions="True">Functions\IPAM\Get-NetboxIPAMChoices.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxTenant_ps1" ExportFunctions="True">Functions\Tenancy\Get-NetboxTenant.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxTenancyChoices_ps1" ExportFunctions="True">Functions\Tenancy\Get-NetboxTenancyChoices.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxVirtualMachine_ps1" ExportFunctions="True">Functions\Virtualization\VirtualMachine\Get-NetboxVirtualMachine.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-New-NetboxVirtualMachine_ps1" ExportFunctions="True">Functions\Virtualization\VirtualMachine\New-NetboxVirtualMachine.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Set-NetboxVirtualMachine_ps1" ExportFunctions="True">Functions\Virtualization\VirtualMachine\Set-NetboxVirtualMachine.ps1</File>
|
||||
<File Build="2" Shared="True" ReferenceFunction="Invoke-Remove-NetboxVirtualMachine_ps1" ExportFunctions="False">Functions\Virtualization\VirtualMachine\Remove-NetboxVirtualMachine.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Remove-NetboxVirtualMachine_ps1" ExportFunctions="True">Functions\Virtualization\VirtualMachine\Remove-NetboxVirtualMachine.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Add-NetboxVirtualMachineInterface_ps1" ExportFunctions="True">Functions\Virtualization\VirtualMachineInterface\Add-NetboxVirtualMachineInterface.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxVirtualMachineInterface_ps1" ExportFunctions="True">Functions\Virtualization\VirtualMachineInterface\Get-NetboxVirtualMachineInterface.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Set-NetboxVirtualMachineInterface_ps1" ExportFunctions="True">Functions\Virtualization\VirtualMachineInterface\Set-NetboxVirtualMachineInterface.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxVirtualizationChoices_ps1" ExportFunctions="True">Functions\Virtualization\Get-NetboxVirtualizationChoices.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxVirtualizationCluster_ps1" ExportFunctions="True">Functions\Virtualization\VirtualizationCluster\Get-NetboxVirtualizationCluster.ps1</File>
|
||||
<File Build="2" Shared="True" ReferenceFunction="Invoke-Get-NetboxVirtualizationClusterGroup_ps1" ExportFunctions="False">Functions\Virtualization\VirtualizationCluster\Get-NetboxVirtualizationClusterGroup.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxVirtualizationClusterGroup_ps1" ExportFunctions="True">Functions\Virtualization\VirtualizationCluster\Get-NetboxVirtualizationClusterGroup.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-ValidateVirtualizationChoice_ps1" ExportFunctions="True">Functions\Virtualization\ValidateVirtualizationChoice.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxDCIMDevice_ps1" ExportFunctions="True">Functions\DCIM\Devices\Get-NetboxDCIMDevice.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxDCIMDeviceType_ps1" ExportFunctions="True">Functions\DCIM\Devices\Get-NetboxDCIMDeviceType.ps1</File>
|
||||
|
|
@ -85,6 +102,7 @@
|
|||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxDCIMChoices_ps1" ExportFunctions="True">Functions\DCIM\Get-NetboxDCIMChoices.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxCircuitsChoices_ps1" ExportFunctions="True">Functions\Circuits\Get-NetboxCircuitsChoices.ps1</File>
|
||||
<File Build="0" Shared="True" ReferenceFunction="Invoke-Get-NetboxCircuit_ps1" ExportFunctions="True">Functions\Circuits\Get-NetboxCircuit.ps1</File>
|
||||
<File Build="2" Shared="True" ReferenceFunction="Invoke-deploy_ps1" ExportFunctions="False">deploy.ps1</File>
|
||||
</Files>
|
||||
<StartupScript>R:\Netbox\NetboxPS\Test-Module.ps1</StartupScript>
|
||||
</Project>
|
||||
Loading…
Add table
Reference in a new issue