diff --git a/appveyor.yml b/appveyor.yml index adbc54b..95913ee 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,7 +13,7 @@ install: } - ps: Install-Module -Name InvokeBuild -RequiredVersion 5.4.1 - ps: Install-Module -Name PSScriptAnalyzer -RequiredVersion 1.16.1 -- ps: Install-Module -Name Pester -RequiredVersion 4.3.1 +- ps: Install-Module -Name Pester -RequiredVersion 4.10.1 - ps: Install-Module -Name PlatyPS -RequiredVersion 0.9.0 environment: diff --git a/module/Private/Get.txt b/module/Private/Get.txt index cf96d28..93b8692 100644 --- a/module/Private/Get.txt +++ b/module/Private/Get.txt @@ -41,21 +41,25 @@ Function Get-nb|short| { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "|long|/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "|long|" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "|long|/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "|long|" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } diff --git a/module/Private/New.txt b/module/Private/New.txt index 20bb55d..ef6f199 100644 --- a/module/Private/New.txt +++ b/module/Private/New.txt @@ -36,10 +36,14 @@ Function New-nb|short| { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource '|long|' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource '|long|' @forward } diff --git a/module/Private/Remove.txt b/module/Private/Remove.txt index 5339fcd..df20889 100644 --- a/module/Private/Remove.txt +++ b/module/Private/Remove.txt @@ -18,5 +18,9 @@ Function Remove-nb|short| { [Int] $Id ) - Remove-nbObject -Resource '|long|' -id $id + try { + Remove-nbObject -Resource '|long|' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } diff --git a/module/Private/Set.txt b/module/Private/Set.txt index d7cb6f6..bf60520 100644 --- a/module/Private/Set.txt +++ b/module/Private/Set.txt @@ -48,12 +48,16 @@ Function Set-nb|short| { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource '|long|' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - Set-nbObject -Resource '|long|' @forward } diff --git a/module/Public/Get-nbObject.ps1 b/module/Public/Get-nbObject.ps1 index 6fe9978..856d54b 100644 --- a/module/Public/Get-nbObject.ps1 +++ b/module/Public/Get-nbObject.ps1 @@ -51,6 +51,9 @@ function Get-nbObject { [uri] $APIUrl ) + trap { + $PSCmdlet.ThrowTerminatingError($_) + } $params = @{} if ($AdditionalParams) { $params += $AdditionalParams diff --git a/module/Public/Get-nbx.ps1 b/module/Public/Get-nbx.ps1 index 2fe3df3..a180a50 100644 --- a/module/Public/Get-nbx.ps1 +++ b/module/Public/Get-nbx.ps1 @@ -5,18 +5,18 @@ <# .SYNOPSIS - Gets a Prefix from Netbox + Gets a VlanGroup from Netbox .DESCRIPTION - Rerieves Prefix objects from netbox and automatically flattens them and + Rerieves VlanGroup objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbPrefix -id 22 + Get-nbVlanGroup -id 22 .EXAMPLE - Get-nbPrefix -query @{name='myPrefix'} + Get-nbVlanGroup -query @{name='myVlanGroup'} .EXAMPLE - Get-nbPrefix myPrefix + Get-nbVlanGroup myVlanGroup #> -Function Get-nbPrefix { +Function Get-nbVlanGroup { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -46,39 +46,43 @@ Function Get-nbPrefix { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "ipam/vlan-groups/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "ipam/vlan-groups" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "ipam/prefixes/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "ipam/prefixes" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a ConsolePortTemplate from Netbox + Gets a ClusterGroup from Netbox .DESCRIPTION - Rerieves ConsolePortTemplate objects from netbox and automatically flattens them and + Rerieves ClusterGroup objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbConsolePortTemplate -id 22 + Get-nbClusterGroup -id 22 .EXAMPLE - Get-nbConsolePortTemplate -query @{name='myConsolePortTemplate'} + Get-nbClusterGroup -query @{name='myClusterGroup'} .EXAMPLE - Get-nbConsolePortTemplate myConsolePortTemplate + Get-nbClusterGroup myClusterGroup #> -Function Get-nbConsolePortTemplate { +Function Get-nbClusterGroup { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -108,39 +112,43 @@ Function Get-nbConsolePortTemplate { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "virtualization/cluster-groups/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "virtualization/cluster-groups" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "dcim/console-port-templates/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "dcim/console-port-templates" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a Interface from Netbox + Gets a DeviceType from Netbox .DESCRIPTION - Rerieves Interface objects from netbox and automatically flattens them and + Rerieves DeviceType objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbInterface -id 22 + Get-nbDeviceType -id 22 .EXAMPLE - Get-nbInterface -query @{name='myInterface'} + Get-nbDeviceType -query @{name='myDeviceType'} .EXAMPLE - Get-nbInterface myInterface + Get-nbDeviceType myDeviceType #> -Function Get-nbInterface { +Function Get-nbDeviceType { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -170,39 +178,43 @@ Function Get-nbInterface { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "dcim/interfaces/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "dcim/interfaces" - $forward['Query'] = $Query - $forward['Search'] = $search + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "dcim/device-types/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "dcim/device-types" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a PowerConnection from Netbox + Gets a PowerOutlet from Netbox .DESCRIPTION - Rerieves PowerConnection objects from netbox and automatically flattens them and + Rerieves PowerOutlet objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbPowerConnection -id 22 + Get-nbPowerOutlet -id 22 .EXAMPLE - Get-nbPowerConnection -query @{name='myPowerConnection'} + Get-nbPowerOutlet -query @{name='myPowerOutlet'} .EXAMPLE - Get-nbPowerConnection myPowerConnection + Get-nbPowerOutlet myPowerOutlet #> -Function Get-nbPowerConnection { +Function Get-nbPowerOutlet { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -232,23 +244,27 @@ Function Get-nbPowerConnection { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "dcim/power-connections/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "dcim/power-connections" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "dcim/power-outlets/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "dcim/power-outlets" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - Get-nbObject @forward } <# @@ -294,39 +310,43 @@ Function Get-nbConnectedDevice { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "dcim/connected-device/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "dcim/connected-device" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "dcim/connected-device/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "dcim/connected-device" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a IpAddress from Netbox + Gets a Region from Netbox .DESCRIPTION - Rerieves IpAddress objects from netbox and automatically flattens them and + Rerieves Region objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbIpAddress -id 22 + Get-nbRegion -id 22 .EXAMPLE - Get-nbIpAddress -query @{name='myIpAddress'} + Get-nbRegion -query @{name='myRegion'} .EXAMPLE - Get-nbIpAddress myIpAddress + Get-nbRegion myRegion #> -Function Get-nbIpAddress { +Function Get-nbRegion { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -356,39 +376,43 @@ Function Get-nbIpAddress { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "dcim/regions/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "dcim/regions" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "ipam/ip-addresses/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "ipam/ip-addresses" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a Aggregate from Netbox + Gets a ConsoleServerPortTemplate from Netbox .DESCRIPTION - Rerieves Aggregate objects from netbox and automatically flattens them and + Rerieves ConsoleServerPortTemplate objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbAggregate -id 22 + Get-nbConsoleServerPortTemplate -id 22 .EXAMPLE - Get-nbAggregate -query @{name='myAggregate'} + Get-nbConsoleServerPortTemplate -query @{name='myConsoleServerPortTemplate'} .EXAMPLE - Get-nbAggregate myAggregate + Get-nbConsoleServerPortTemplate myConsoleServerPortTemplate #> -Function Get-nbAggregate { +Function Get-nbConsoleServerPortTemplate { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -418,39 +442,43 @@ Function Get-nbAggregate { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "ipam/aggregates/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "ipam/aggregates" - $forward['Query'] = $Query - $forward['Search'] = $search + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "dcim/console-server-port-templates/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "dcim/console-server-port-templates" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a PowerPortTemplate from Netbox + Gets a Aggregate from Netbox .DESCRIPTION - Rerieves PowerPortTemplate objects from netbox and automatically flattens them and + Rerieves Aggregate objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbPowerPortTemplate -id 22 + Get-nbAggregate -id 22 .EXAMPLE - Get-nbPowerPortTemplate -query @{name='myPowerPortTemplate'} + Get-nbAggregate -query @{name='myAggregate'} .EXAMPLE - Get-nbPowerPortTemplate myPowerPortTemplate + Get-nbAggregate myAggregate #> -Function Get-nbPowerPortTemplate { +Function Get-nbAggregate { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -480,39 +508,43 @@ Function Get-nbPowerPortTemplate { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "dcim/power-port-templates/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "dcim/power-port-templates" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "ipam/aggregates/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "ipam/aggregates" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - Get-nbObject @forward } <# .SYNOPSIS - Gets a ImageAttachment from Netbox + Gets a ClusterType from Netbox .DESCRIPTION - Rerieves ImageAttachment objects from netbox and automatically flattens them and + Rerieves ClusterType objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbImageAttachment -id 22 + Get-nbClusterType -id 22 .EXAMPLE - Get-nbImageAttachment -query @{name='myImageAttachment'} + Get-nbClusterType -query @{name='myClusterType'} .EXAMPLE - Get-nbImageAttachment myImageAttachment + Get-nbClusterType myClusterType #> -Function Get-nbImageAttachment { +Function Get-nbClusterType { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -542,39 +574,43 @@ Function Get-nbImageAttachment { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "virtualization/cluster-types/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "virtualization/cluster-types" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "extras/image-attachments/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "extras/image-attachments" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a ConsoleServerPort from Netbox + Gets a Vlan from Netbox .DESCRIPTION - Rerieves ConsoleServerPort objects from netbox and automatically flattens them and + Rerieves Vlan objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbConsoleServerPort -id 22 + Get-nbVlan -id 22 .EXAMPLE - Get-nbConsoleServerPort -query @{name='myConsoleServerPort'} + Get-nbVlan -query @{name='myVlan'} .EXAMPLE - Get-nbConsoleServerPort myConsoleServerPort + Get-nbVlan myVlan #> -Function Get-nbConsoleServerPort { +Function Get-nbVlan { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -604,39 +640,43 @@ Function Get-nbConsoleServerPort { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "ipam/vlans/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "ipam/vlans" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "dcim/console-server-ports/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "dcim/console-server-ports" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a InventoryItem from Netbox + Gets a Provider from Netbox .DESCRIPTION - Rerieves InventoryItem objects from netbox and automatically flattens them and + Rerieves Provider objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbInventoryItem -id 22 + Get-nbProvider -id 22 .EXAMPLE - Get-nbInventoryItem -query @{name='myInventoryItem'} + Get-nbProvider -query @{name='myProvider'} .EXAMPLE - Get-nbInventoryItem myInventoryItem + Get-nbProvider myProvider #> -Function Get-nbInventoryItem { +Function Get-nbProvider { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -666,39 +706,43 @@ Function Get-nbInventoryItem { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "dcim/inventory-items/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "dcim/inventory-items" - $forward['Query'] = $Query - $forward['Search'] = $search + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "circuits/providers/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "circuits/providers" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a Service from Netbox + Gets a PowerConnection from Netbox .DESCRIPTION - Rerieves Service objects from netbox and automatically flattens them and + Rerieves PowerConnection objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbService -id 22 + Get-nbPowerConnection -id 22 .EXAMPLE - Get-nbService -query @{name='myService'} + Get-nbPowerConnection -query @{name='myPowerConnection'} .EXAMPLE - Get-nbService myService + Get-nbPowerConnection myPowerConnection #> -Function Get-nbService { +Function Get-nbPowerConnection { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -728,39 +772,43 @@ Function Get-nbService { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "ipam/services/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "ipam/services" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "dcim/power-connections/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "dcim/power-connections" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - Get-nbObject @forward } <# .SYNOPSIS - Gets a ConsoleServerPortTemplate from Netbox + Gets a ConsolePort from Netbox .DESCRIPTION - Rerieves ConsoleServerPortTemplate objects from netbox and automatically flattens them and + Rerieves ConsolePort objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbConsoleServerPortTemplate -id 22 + Get-nbConsolePort -id 22 .EXAMPLE - Get-nbConsoleServerPortTemplate -query @{name='myConsoleServerPortTemplate'} + Get-nbConsolePort -query @{name='myConsolePort'} .EXAMPLE - Get-nbConsoleServerPortTemplate myConsoleServerPortTemplate + Get-nbConsolePort myConsolePort #> -Function Get-nbConsoleServerPortTemplate { +Function Get-nbConsolePort { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -790,39 +838,43 @@ Function Get-nbConsoleServerPortTemplate { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "dcim/console-ports/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "dcim/console-ports" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "dcim/console-server-port-templates/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "dcim/console-server-port-templates" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a VirtualMachine from Netbox + Gets a VMInterface from Netbox .DESCRIPTION - Rerieves VirtualMachine objects from netbox and automatically flattens them and + Rerieves VMInterface objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbVirtualMachine -id 22 + Get-nbVMInterface -id 22 .EXAMPLE - Get-nbVirtualMachine -query @{name='myVirtualMachine'} + Get-nbVMInterface -query @{name='myVMInterface'} .EXAMPLE - Get-nbVirtualMachine myVirtualMachine + Get-nbVMInterface myVMInterface #> -Function Get-nbVirtualMachine { +Function Get-nbVMInterface { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -852,39 +904,43 @@ Function Get-nbVirtualMachine { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "virtualization/interfaces/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "virtualization/interfaces" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "virtualization/virtual-machines/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "virtualization/virtual-machines" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a Rir from Netbox + Gets a Platform from Netbox .DESCRIPTION - Rerieves Rir objects from netbox and automatically flattens them and + Rerieves Platform objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbRir -id 22 + Get-nbPlatform -id 22 .EXAMPLE - Get-nbRir -query @{name='myRir'} + Get-nbPlatform -query @{name='myPlatform'} .EXAMPLE - Get-nbRir myRir + Get-nbPlatform myPlatform #> -Function Get-nbRir { +Function Get-nbPlatform { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -914,39 +970,43 @@ Function Get-nbRir { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "ipam/rirs/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "ipam/rirs" - $forward['Query'] = $Query - $forward['Search'] = $search + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "dcim/platforms/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "dcim/platforms" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a Report from Netbox + Gets a Circuit from Netbox .DESCRIPTION - Rerieves Report objects from netbox and automatically flattens them and + Rerieves Circuit objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbReport -id 22 + Get-nbCircuit -id 22 .EXAMPLE - Get-nbReport -query @{name='myReport'} + Get-nbCircuit -query @{name='myCircuit'} .EXAMPLE - Get-nbReport myReport + Get-nbCircuit myCircuit #> -Function Get-nbReport { +Function Get-nbCircuit { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -976,39 +1036,43 @@ Function Get-nbReport { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "extras/reports/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "extras/reports" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "circuits/circuits/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "circuits/circuits" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - Get-nbObject @forward } <# .SYNOPSIS - Gets a TenantGroup from Netbox + Gets a RackReservation from Netbox .DESCRIPTION - Rerieves TenantGroup objects from netbox and automatically flattens them and + Rerieves RackReservation objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbTenantGroup -id 22 + Get-nbRackReservation -id 22 .EXAMPLE - Get-nbTenantGroup -query @{name='myTenantGroup'} + Get-nbRackReservation -query @{name='myRackReservation'} .EXAMPLE - Get-nbTenantGroup myTenantGroup + Get-nbRackReservation myRackReservation #> -Function Get-nbTenantGroup { +Function Get-nbRackReservation { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -1038,39 +1102,43 @@ Function Get-nbTenantGroup { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "dcim/rack-reservations/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "dcim/rack-reservations" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "tenancy/tenant-groups/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "tenancy/tenant-groups" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a TopologyMap from Netbox + Gets a TenantGroup from Netbox .DESCRIPTION - Rerieves TopologyMap objects from netbox and automatically flattens them and + Rerieves TenantGroup objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbTopologyMap -id 22 + Get-nbTenantGroup -id 22 .EXAMPLE - Get-nbTopologyMap -query @{name='myTopologyMap'} + Get-nbTenantGroup -query @{name='myTenantGroup'} .EXAMPLE - Get-nbTopologyMap myTopologyMap + Get-nbTenantGroup myTenantGroup #> -Function Get-nbTopologyMap { +Function Get-nbTenantGroup { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -1100,39 +1168,43 @@ Function Get-nbTopologyMap { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "tenancy/tenant-groups/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "tenancy/tenant-groups" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "extras/topology-maps/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "extras/topology-maps" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a RackGroup from Netbox + Gets a Devicebay from Netbox .DESCRIPTION - Rerieves RackGroup objects from netbox and automatically flattens them and + Rerieves Devicebay objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbRackGroup -id 22 + Get-nbDevicebay -id 22 .EXAMPLE - Get-nbRackGroup -query @{name='myRackGroup'} + Get-nbDevicebay -query @{name='myDevicebay'} .EXAMPLE - Get-nbRackGroup myRackGroup + Get-nbDevicebay myDevicebay #> -Function Get-nbRackGroup { +Function Get-nbDevicebay { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -1162,39 +1234,43 @@ Function Get-nbRackGroup { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "dcim/device-bays/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "dcim/device-bays" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "dcim/rack-groups/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "dcim/rack-groups" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a Provider from Netbox + Gets a Rir from Netbox .DESCRIPTION - Rerieves Provider objects from netbox and automatically flattens them and + Rerieves Rir objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbProvider -id 22 + Get-nbRir -id 22 .EXAMPLE - Get-nbProvider -query @{name='myProvider'} + Get-nbRir -query @{name='myRir'} .EXAMPLE - Get-nbProvider myProvider + Get-nbRir myRir #> -Function Get-nbProvider { +Function Get-nbRir { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -1224,39 +1300,43 @@ Function Get-nbProvider { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "ipam/rirs/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "ipam/rirs" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "circuits/providers/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "circuits/providers" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a RackReservation from Netbox + Gets a DevicebayTemplate from Netbox .DESCRIPTION - Rerieves RackReservation objects from netbox and automatically flattens them and + Rerieves DevicebayTemplate objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbRackReservation -id 22 + Get-nbDevicebayTemplate -id 22 .EXAMPLE - Get-nbRackReservation -query @{name='myRackReservation'} + Get-nbDevicebayTemplate -query @{name='myDevicebayTemplate'} .EXAMPLE - Get-nbRackReservation myRackReservation + Get-nbDevicebayTemplate myDevicebayTemplate #> -Function Get-nbRackReservation { +Function Get-nbDevicebayTemplate { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -1286,39 +1366,43 @@ Function Get-nbRackReservation { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "dcim/rack-reservations/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "dcim/rack-reservations" - $forward['Query'] = $Query - $forward['Search'] = $search + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "dcim/device-bay-templates/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "dcim/device-bay-templates" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a PowerOutletTemplate from Netbox + Gets a Graph from Netbox .DESCRIPTION - Rerieves PowerOutletTemplate objects from netbox and automatically flattens them and + Rerieves Graph objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbPowerOutletTemplate -id 22 + Get-nbGraph -id 22 .EXAMPLE - Get-nbPowerOutletTemplate -query @{name='myPowerOutletTemplate'} + Get-nbGraph -query @{name='myGraph'} .EXAMPLE - Get-nbPowerOutletTemplate myPowerOutletTemplate + Get-nbGraph myGraph #> -Function Get-nbPowerOutletTemplate { +Function Get-nbGraph { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -1348,39 +1432,43 @@ Function Get-nbPowerOutletTemplate { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "dcim/power-outlet-templates/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "dcim/power-outlet-templates" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "extras/graphs/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "extras/graphs" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - Get-nbObject @forward } <# .SYNOPSIS - Gets a PowerOutlet from Netbox + Gets a Interface from Netbox .DESCRIPTION - Rerieves PowerOutlet objects from netbox and automatically flattens them and + Rerieves Interface objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbPowerOutlet -id 22 + Get-nbInterface -id 22 .EXAMPLE - Get-nbPowerOutlet -query @{name='myPowerOutlet'} + Get-nbInterface -query @{name='myInterface'} .EXAMPLE - Get-nbPowerOutlet myPowerOutlet + Get-nbInterface myInterface #> -Function Get-nbPowerOutlet { +Function Get-nbInterface { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -1410,39 +1498,43 @@ Function Get-nbPowerOutlet { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "dcim/power-outlets/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "dcim/power-outlets" - $forward['Query'] = $Query - $forward['Search'] = $search + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "dcim/interfaces/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "dcim/interfaces" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a Circuit from Netbox + Gets a InterfaceConnection from Netbox .DESCRIPTION - Rerieves Circuit objects from netbox and automatically flattens them and + Rerieves InterfaceConnection objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbCircuit -id 22 + Get-nbInterfaceConnection -id 22 .EXAMPLE - Get-nbCircuit -query @{name='myCircuit'} + Get-nbInterfaceConnection -query @{name='myInterfaceConnection'} .EXAMPLE - Get-nbCircuit myCircuit + Get-nbInterfaceConnection myInterfaceConnection #> -Function Get-nbCircuit { +Function Get-nbInterfaceConnection { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -1472,39 +1564,43 @@ Function Get-nbCircuit { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "circuits/circuits/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "circuits/circuits" - $forward['Query'] = $Query - $forward['Search'] = $search + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "dcim/interface-connections/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "dcim/interface-connections" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a Graph from Netbox + Gets a Role from Netbox .DESCRIPTION - Rerieves Graph objects from netbox and automatically flattens them and + Rerieves Role objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbGraph -id 22 + Get-nbRole -id 22 .EXAMPLE - Get-nbGraph -query @{name='myGraph'} + Get-nbRole -query @{name='myRole'} .EXAMPLE - Get-nbGraph myGraph + Get-nbRole myRole #> -Function Get-nbGraph { +Function Get-nbRole { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -1534,39 +1630,43 @@ Function Get-nbGraph { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "ipam/roles/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "ipam/roles" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "extras/graphs/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "extras/graphs" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a Device from Netbox + Gets a ImageAttachment from Netbox .DESCRIPTION - Rerieves Device objects from netbox and automatically flattens them and + Rerieves ImageAttachment objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbDevice -id 22 + Get-nbImageAttachment -id 22 .EXAMPLE - Get-nbDevice -query @{name='myDevice'} + Get-nbImageAttachment -query @{name='myImageAttachment'} .EXAMPLE - Get-nbDevice myDevice + Get-nbImageAttachment myImageAttachment #> -Function Get-nbDevice { +Function Get-nbImageAttachment { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -1596,39 +1696,43 @@ Function Get-nbDevice { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "extras/image-attachments/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "extras/image-attachments" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "dcim/devices/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "dcim/devices" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a VirtualChassis from Netbox + Gets a Rack from Netbox .DESCRIPTION - Rerieves VirtualChassis objects from netbox and automatically flattens them and + Rerieves Rack objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbVirtualChassis -id 22 + Get-nbRack -id 22 .EXAMPLE - Get-nbVirtualChassis -query @{name='myVirtualChassis'} + Get-nbRack -query @{name='myRack'} .EXAMPLE - Get-nbVirtualChassis myVirtualChassis + Get-nbRack myRack #> -Function Get-nbVirtualChassis { +Function Get-nbRack { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -1658,39 +1762,43 @@ Function Get-nbVirtualChassis { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "dcim/virtual-chassis/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "dcim/virtual-chassis" - $forward['Query'] = $Query - $forward['Search'] = $search + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "dcim/racks/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "dcim/racks" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a DevicebayTemplate from Netbox + Gets a ConsolePortTemplate from Netbox .DESCRIPTION - Rerieves DevicebayTemplate objects from netbox and automatically flattens them and + Rerieves ConsolePortTemplate objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbDevicebayTemplate -id 22 + Get-nbConsolePortTemplate -id 22 .EXAMPLE - Get-nbDevicebayTemplate -query @{name='myDevicebayTemplate'} + Get-nbConsolePortTemplate -query @{name='myConsolePortTemplate'} .EXAMPLE - Get-nbDevicebayTemplate myDevicebayTemplate + Get-nbConsolePortTemplate myConsolePortTemplate #> -Function Get-nbDevicebayTemplate { +Function Get-nbConsolePortTemplate { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -1720,39 +1828,43 @@ Function Get-nbDevicebayTemplate { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "dcim/device-bay-templates/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "dcim/device-bay-templates" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "dcim/console-port-templates/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "dcim/console-port-templates" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - Get-nbObject @forward } <# .SYNOPSIS - Gets a ConsoleConnection from Netbox + Gets a InterfaceTemplate from Netbox .DESCRIPTION - Rerieves ConsoleConnection objects from netbox and automatically flattens them and + Rerieves InterfaceTemplate objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbConsoleConnection -id 22 + Get-nbInterfaceTemplate -id 22 .EXAMPLE - Get-nbConsoleConnection -query @{name='myConsoleConnection'} + Get-nbInterfaceTemplate -query @{name='myInterfaceTemplate'} .EXAMPLE - Get-nbConsoleConnection myConsoleConnection + Get-nbInterfaceTemplate myInterfaceTemplate #> -Function Get-nbConsoleConnection { +Function Get-nbInterfaceTemplate { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -1782,39 +1894,43 @@ Function Get-nbConsoleConnection { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "dcim/console-connections/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "dcim/console-connections" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "dcim/interface-templates/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "dcim/interface-templates" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - Get-nbObject @forward } <# .SYNOPSIS - Gets a RackRole from Netbox + Gets a ExportTemplate from Netbox .DESCRIPTION - Rerieves RackRole objects from netbox and automatically flattens them and + Rerieves ExportTemplate objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbRackRole -id 22 + Get-nbExportTemplate -id 22 .EXAMPLE - Get-nbRackRole -query @{name='myRackRole'} + Get-nbExportTemplate -query @{name='myExportTemplate'} .EXAMPLE - Get-nbRackRole myRackRole + Get-nbExportTemplate myExportTemplate #> -Function Get-nbRackRole { +Function Get-nbExportTemplate { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -1844,39 +1960,43 @@ Function Get-nbRackRole { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "dcim/rack-roles/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "dcim/rack-roles" - $forward['Query'] = $Query - $forward['Search'] = $search + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "extras/export-templates/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "extras/export-templates" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a Platform from Netbox + Gets a Cluster from Netbox .DESCRIPTION - Rerieves Platform objects from netbox and automatically flattens them and + Rerieves Cluster objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbPlatform -id 22 + Get-nbCluster -id 22 .EXAMPLE - Get-nbPlatform -query @{name='myPlatform'} + Get-nbCluster -query @{name='myCluster'} .EXAMPLE - Get-nbPlatform myPlatform + Get-nbCluster myCluster #> -Function Get-nbPlatform { +Function Get-nbCluster { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -1906,39 +2026,43 @@ Function Get-nbPlatform { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "virtualization/clusters/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "virtualization/clusters" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "dcim/platforms/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "dcim/platforms" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a Vlan from Netbox + Gets a Service from Netbox .DESCRIPTION - Rerieves Vlan objects from netbox and automatically flattens them and + Rerieves Service objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbVlan -id 22 + Get-nbService -id 22 .EXAMPLE - Get-nbVlan -query @{name='myVlan'} + Get-nbService -query @{name='myService'} .EXAMPLE - Get-nbVlan myVlan + Get-nbService myService #> -Function Get-nbVlan { +Function Get-nbService { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -1968,39 +2092,43 @@ Function Get-nbVlan { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "ipam/services/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "ipam/services" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "ipam/vlans/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "ipam/vlans" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a RecentActivity from Netbox + Gets a RackRole from Netbox .DESCRIPTION - Rerieves RecentActivity objects from netbox and automatically flattens them and + Rerieves RackRole objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbRecentActivity -id 22 + Get-nbRackRole -id 22 .EXAMPLE - Get-nbRecentActivity -query @{name='myRecentActivity'} + Get-nbRackRole -query @{name='myRackRole'} .EXAMPLE - Get-nbRecentActivity myRecentActivity + Get-nbRackRole myRackRole #> -Function Get-nbRecentActivity { +Function Get-nbRackRole { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -2030,39 +2158,43 @@ Function Get-nbRecentActivity { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "dcim/rack-roles/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "dcim/rack-roles" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "extras/recent-activity/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "extras/recent-activity" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a Region from Netbox + Gets a CircuitType from Netbox .DESCRIPTION - Rerieves Region objects from netbox and automatically flattens them and + Rerieves CircuitType objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbRegion -id 22 + Get-nbCircuitType -id 22 .EXAMPLE - Get-nbRegion -query @{name='myRegion'} + Get-nbCircuitType -query @{name='myCircuitType'} .EXAMPLE - Get-nbRegion myRegion + Get-nbCircuitType myCircuitType #> -Function Get-nbRegion { +Function Get-nbCircuitType { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -2092,39 +2224,43 @@ Function Get-nbRegion { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "dcim/regions/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "dcim/regions" - $forward['Query'] = $Query - $forward['Search'] = $search + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "circuits/circuit-types/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "circuits/circuit-types" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a Manufacturer from Netbox + Gets a Report from Netbox .DESCRIPTION - Rerieves Manufacturer objects from netbox and automatically flattens them and + Rerieves Report objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbManufacturer -id 22 + Get-nbReport -id 22 .EXAMPLE - Get-nbManufacturer -query @{name='myManufacturer'} + Get-nbReport -query @{name='myReport'} .EXAMPLE - Get-nbManufacturer myManufacturer + Get-nbReport myReport #> -Function Get-nbManufacturer { +Function Get-nbReport { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -2154,39 +2290,43 @@ Function Get-nbManufacturer { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "dcim/manufacturers/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "dcim/manufacturers" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "extras/reports/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "extras/reports" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - Get-nbObject @forward } <# .SYNOPSIS - Gets a VlanGroup from Netbox + Gets a Manufacturer from Netbox .DESCRIPTION - Rerieves VlanGroup objects from netbox and automatically flattens them and + Rerieves Manufacturer objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbVlanGroup -id 22 + Get-nbManufacturer -id 22 .EXAMPLE - Get-nbVlanGroup -query @{name='myVlanGroup'} + Get-nbManufacturer -query @{name='myManufacturer'} .EXAMPLE - Get-nbVlanGroup myVlanGroup + Get-nbManufacturer myManufacturer #> -Function Get-nbVlanGroup { +Function Get-nbManufacturer { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -2216,39 +2356,43 @@ Function Get-nbVlanGroup { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "ipam/vlan-groups/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "ipam/vlan-groups" - $forward['Query'] = $Query - $forward['Search'] = $search + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "dcim/manufacturers/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "dcim/manufacturers" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a Tenant from Netbox + Gets a RackGroup from Netbox .DESCRIPTION - Rerieves Tenant objects from netbox and automatically flattens them and + Rerieves RackGroup objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbTenant -id 22 + Get-nbRackGroup -id 22 .EXAMPLE - Get-nbTenant -query @{name='myTenant'} + Get-nbRackGroup -query @{name='myRackGroup'} .EXAMPLE - Get-nbTenant myTenant + Get-nbRackGroup myRackGroup #> -Function Get-nbTenant { +Function Get-nbRackGroup { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -2278,39 +2422,43 @@ Function Get-nbTenant { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "dcim/rack-groups/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "dcim/rack-groups" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "tenancy/tenants/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "tenancy/tenants" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a DeviceType from Netbox + Gets a IpAddress from Netbox .DESCRIPTION - Rerieves DeviceType objects from netbox and automatically flattens them and + Rerieves IpAddress objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbDeviceType -id 22 + Get-nbIpAddress -id 22 .EXAMPLE - Get-nbDeviceType -query @{name='myDeviceType'} + Get-nbIpAddress -query @{name='myIpAddress'} .EXAMPLE - Get-nbDeviceType myDeviceType + Get-nbIpAddress myIpAddress #> -Function Get-nbDeviceType { +Function Get-nbIpAddress { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -2339,40 +2487,44 @@ Function Get-nbDeviceType { [Parameter(ParameterSetName = 'query')] [uri] $APIUrl - ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "dcim/device-types/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "dcim/device-types" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl + ) + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "ipam/ip-addresses/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "ipam/ip-addresses" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - Get-nbObject @forward } <# .SYNOPSIS - Gets a CircuitTermination from Netbox + Gets a Vrf from Netbox .DESCRIPTION - Rerieves CircuitTermination objects from netbox and automatically flattens them and + Rerieves Vrf objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbCircuitTermination -id 22 + Get-nbVrf -id 22 .EXAMPLE - Get-nbCircuitTermination -query @{name='myCircuitTermination'} + Get-nbVrf -query @{name='myVrf'} .EXAMPLE - Get-nbCircuitTermination myCircuitTermination + Get-nbVrf myVrf #> -Function Get-nbCircuitTermination { +Function Get-nbVrf { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -2402,39 +2554,43 @@ Function Get-nbCircuitTermination { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "circuits/circuit-terminations/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "circuits/circuit-terminations" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "ipam/vrfs/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "ipam/vrfs" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - Get-nbObject @forward } <# .SYNOPSIS - Gets a ClusterType from Netbox + Gets a Device from Netbox .DESCRIPTION - Rerieves ClusterType objects from netbox and automatically flattens them and + Rerieves Device objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbClusterType -id 22 + Get-nbDevice -id 22 .EXAMPLE - Get-nbClusterType -query @{name='myClusterType'} + Get-nbDevice -query @{name='myDevice'} .EXAMPLE - Get-nbClusterType myClusterType + Get-nbDevice myDevice #> -Function Get-nbClusterType { +Function Get-nbDevice { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -2464,39 +2620,43 @@ Function Get-nbClusterType { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "dcim/devices/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "dcim/devices" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "virtualization/cluster-types/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "virtualization/cluster-types" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a PowerPort from Netbox + Gets a Tenant from Netbox .DESCRIPTION - Rerieves PowerPort objects from netbox and automatically flattens them and + Rerieves Tenant objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbPowerPort -id 22 + Get-nbTenant -id 22 .EXAMPLE - Get-nbPowerPort -query @{name='myPowerPort'} + Get-nbTenant -query @{name='myTenant'} .EXAMPLE - Get-nbPowerPort myPowerPort + Get-nbTenant myTenant #> -Function Get-nbPowerPort { +Function Get-nbTenant { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -2526,39 +2686,43 @@ Function Get-nbPowerPort { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "tenancy/tenants/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "tenancy/tenants" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "dcim/power-ports/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "dcim/power-ports" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a Role from Netbox + Gets a PowerOutletTemplate from Netbox .DESCRIPTION - Rerieves Role objects from netbox and automatically flattens them and + Rerieves PowerOutletTemplate objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbRole -id 22 + Get-nbPowerOutletTemplate -id 22 .EXAMPLE - Get-nbRole -query @{name='myRole'} + Get-nbPowerOutletTemplate -query @{name='myPowerOutletTemplate'} .EXAMPLE - Get-nbRole myRole + Get-nbPowerOutletTemplate myPowerOutletTemplate #> -Function Get-nbRole { +Function Get-nbPowerOutletTemplate { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -2588,39 +2752,43 @@ Function Get-nbRole { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "ipam/roles/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "ipam/roles" - $forward['Query'] = $Query - $forward['Search'] = $search + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "dcim/power-outlet-templates/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "dcim/power-outlet-templates" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a Vrf from Netbox + Gets a InventoryItem from Netbox .DESCRIPTION - Rerieves Vrf objects from netbox and automatically flattens them and + Rerieves InventoryItem objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbVrf -id 22 + Get-nbInventoryItem -id 22 .EXAMPLE - Get-nbVrf -query @{name='myVrf'} + Get-nbInventoryItem -query @{name='myInventoryItem'} .EXAMPLE - Get-nbVrf myVrf + Get-nbInventoryItem myInventoryItem #> -Function Get-nbVrf { +Function Get-nbInventoryItem { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -2650,39 +2818,43 @@ Function Get-nbVrf { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "ipam/vrfs/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "ipam/vrfs" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "dcim/inventory-items/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "dcim/inventory-items" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - Get-nbObject @forward } <# .SYNOPSIS - Gets a Rack from Netbox + Gets a ConsoleServerPort from Netbox .DESCRIPTION - Rerieves Rack objects from netbox and automatically flattens them and + Rerieves ConsoleServerPort objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbRack -id 22 + Get-nbConsoleServerPort -id 22 .EXAMPLE - Get-nbRack -query @{name='myRack'} + Get-nbConsoleServerPort -query @{name='myConsoleServerPort'} .EXAMPLE - Get-nbRack myRack + Get-nbConsoleServerPort myConsoleServerPort #> -Function Get-nbRack { +Function Get-nbConsoleServerPort { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -2712,39 +2884,43 @@ Function Get-nbRack { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "dcim/console-server-ports/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "dcim/console-server-ports" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "dcim/racks/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "dcim/racks" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a Cluster from Netbox + Gets a VirtualChassis from Netbox .DESCRIPTION - Rerieves Cluster objects from netbox and automatically flattens them and + Rerieves VirtualChassis objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbCluster -id 22 + Get-nbVirtualChassis -id 22 .EXAMPLE - Get-nbCluster -query @{name='myCluster'} + Get-nbVirtualChassis -query @{name='myVirtualChassis'} .EXAMPLE - Get-nbCluster myCluster + Get-nbVirtualChassis myVirtualChassis #> -Function Get-nbCluster { +Function Get-nbVirtualChassis { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -2774,39 +2950,43 @@ Function Get-nbCluster { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "dcim/virtual-chassis/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "dcim/virtual-chassis" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "virtualization/clusters/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "virtualization/clusters" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a Site from Netbox + Gets a VirtualMachine from Netbox .DESCRIPTION - Rerieves Site objects from netbox and automatically flattens them and + Rerieves VirtualMachine objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbSite -id 22 + Get-nbVirtualMachine -id 22 .EXAMPLE - Get-nbSite -query @{name='mySite'} + Get-nbVirtualMachine -query @{name='myVirtualMachine'} .EXAMPLE - Get-nbSite mySite + Get-nbVirtualMachine myVirtualMachine #> -Function Get-nbSite { +Function Get-nbVirtualMachine { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -2836,39 +3016,43 @@ Function Get-nbSite { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "dcim/sites/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "dcim/sites" - $forward['Query'] = $Query - $forward['Search'] = $search + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "virtualization/virtual-machines/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "virtualization/virtual-machines" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a ClusterGroup from Netbox + Gets a PowerPort from Netbox .DESCRIPTION - Rerieves ClusterGroup objects from netbox and automatically flattens them and + Rerieves PowerPort objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbClusterGroup -id 22 + Get-nbPowerPort -id 22 .EXAMPLE - Get-nbClusterGroup -query @{name='myClusterGroup'} + Get-nbPowerPort -query @{name='myPowerPort'} .EXAMPLE - Get-nbClusterGroup myClusterGroup + Get-nbPowerPort myPowerPort #> -Function Get-nbClusterGroup { +Function Get-nbPowerPort { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -2898,39 +3082,43 @@ Function Get-nbClusterGroup { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "virtualization/cluster-groups/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "virtualization/cluster-groups" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "dcim/power-ports/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "dcim/power-ports" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - Get-nbObject @forward } <# .SYNOPSIS - Gets a InterfaceConnection from Netbox + Gets a PowerPortTemplate from Netbox .DESCRIPTION - Rerieves InterfaceConnection objects from netbox and automatically flattens them and + Rerieves PowerPortTemplate objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbInterfaceConnection -id 22 + Get-nbPowerPortTemplate -id 22 .EXAMPLE - Get-nbInterfaceConnection -query @{name='myInterfaceConnection'} + Get-nbPowerPortTemplate -query @{name='myPowerPortTemplate'} .EXAMPLE - Get-nbInterfaceConnection myInterfaceConnection + Get-nbPowerPortTemplate myPowerPortTemplate #> -Function Get-nbInterfaceConnection { +Function Get-nbPowerPortTemplate { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -2960,39 +3148,43 @@ Function Get-nbInterfaceConnection { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "dcim/power-port-templates/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "dcim/power-port-templates" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "dcim/interface-connections/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "dcim/interface-connections" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a CircuitType from Netbox + Gets a ConsoleConnection from Netbox .DESCRIPTION - Rerieves CircuitType objects from netbox and automatically flattens them and + Rerieves ConsoleConnection objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbCircuitType -id 22 + Get-nbConsoleConnection -id 22 .EXAMPLE - Get-nbCircuitType -query @{name='myCircuitType'} + Get-nbConsoleConnection -query @{name='myConsoleConnection'} .EXAMPLE - Get-nbCircuitType myCircuitType + Get-nbConsoleConnection myConsoleConnection #> -Function Get-nbCircuitType { +Function Get-nbConsoleConnection { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -3022,39 +3214,43 @@ Function Get-nbCircuitType { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "dcim/console-connections/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "dcim/console-connections" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "circuits/circuit-types/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "circuits/circuit-types" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a DeviceRole from Netbox + Gets a TopologyMap from Netbox .DESCRIPTION - Rerieves DeviceRole objects from netbox and automatically flattens them and + Rerieves TopologyMap objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbDeviceRole -id 22 + Get-nbTopologyMap -id 22 .EXAMPLE - Get-nbDeviceRole -query @{name='myDeviceRole'} + Get-nbTopologyMap -query @{name='myTopologyMap'} .EXAMPLE - Get-nbDeviceRole myDeviceRole + Get-nbTopologyMap myTopologyMap #> -Function Get-nbDeviceRole { +Function Get-nbTopologyMap { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -3084,39 +3280,43 @@ Function Get-nbDeviceRole { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "dcim/device-roles/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "dcim/device-roles" - $forward['Query'] = $Query - $forward['Search'] = $search + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "extras/topology-maps/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "extras/topology-maps" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a VMInterface from Netbox + Gets a CircuitTermination from Netbox .DESCRIPTION - Rerieves VMInterface objects from netbox and automatically flattens them and + Rerieves CircuitTermination objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbVMInterface -id 22 + Get-nbCircuitTermination -id 22 .EXAMPLE - Get-nbVMInterface -query @{name='myVMInterface'} + Get-nbCircuitTermination -query @{name='myCircuitTermination'} .EXAMPLE - Get-nbVMInterface myVMInterface + Get-nbCircuitTermination myCircuitTermination #> -Function Get-nbVMInterface { +Function Get-nbCircuitTermination { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -3146,39 +3346,43 @@ Function Get-nbVMInterface { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "virtualization/interfaces/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "virtualization/interfaces" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "circuits/circuit-terminations/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "circuits/circuit-terminations" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - Get-nbObject @forward } <# .SYNOPSIS - Gets a ConsolePort from Netbox + Gets a RecentActivity from Netbox .DESCRIPTION - Rerieves ConsolePort objects from netbox and automatically flattens them and + Rerieves RecentActivity objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbConsolePort -id 22 + Get-nbRecentActivity -id 22 .EXAMPLE - Get-nbConsolePort -query @{name='myConsolePort'} + Get-nbRecentActivity -query @{name='myRecentActivity'} .EXAMPLE - Get-nbConsolePort myConsolePort + Get-nbRecentActivity myRecentActivity #> -Function Get-nbConsolePort { +Function Get-nbRecentActivity { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -3208,39 +3412,43 @@ Function Get-nbConsolePort { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "extras/recent-activity/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "extras/recent-activity" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "dcim/console-ports/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "dcim/console-ports" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a Devicebay from Netbox + Gets a Prefix from Netbox .DESCRIPTION - Rerieves Devicebay objects from netbox and automatically flattens them and + Rerieves Prefix objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbDevicebay -id 22 + Get-nbPrefix -id 22 .EXAMPLE - Get-nbDevicebay -query @{name='myDevicebay'} + Get-nbPrefix -query @{name='myPrefix'} .EXAMPLE - Get-nbDevicebay myDevicebay + Get-nbPrefix myPrefix #> -Function Get-nbDevicebay { +Function Get-nbPrefix { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -3270,39 +3478,43 @@ Function Get-nbDevicebay { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "ipam/prefixes/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "ipam/prefixes" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "dcim/device-bays/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "dcim/device-bays" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a InterfaceTemplate from Netbox + Gets a DeviceRole from Netbox .DESCRIPTION - Rerieves InterfaceTemplate objects from netbox and automatically flattens them and + Rerieves DeviceRole objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbInterfaceTemplate -id 22 + Get-nbDeviceRole -id 22 .EXAMPLE - Get-nbInterfaceTemplate -query @{name='myInterfaceTemplate'} + Get-nbDeviceRole -query @{name='myDeviceRole'} .EXAMPLE - Get-nbInterfaceTemplate myInterfaceTemplate + Get-nbDeviceRole myDeviceRole #> -Function Get-nbInterfaceTemplate { +Function Get-nbDeviceRole { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -3332,39 +3544,43 @@ Function Get-nbInterfaceTemplate { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "dcim/interface-templates/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "dcim/interface-templates" - $forward['Query'] = $Query - $forward['Search'] = $search + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "dcim/device-roles/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "dcim/device-roles" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl - } - Get-nbObject @forward } <# .SYNOPSIS - Gets a ExportTemplate from Netbox + Gets a Site from Netbox .DESCRIPTION - Rerieves ExportTemplate objects from netbox and automatically flattens them and + Rerieves Site objects from netbox and automatically flattens them and preps them for further processing .EXAMPLE - Get-nbExportTemplate -id 22 + Get-nbSite -id 22 .EXAMPLE - Get-nbExportTemplate -query @{name='myExportTemplate'} + Get-nbSite -query @{name='mySite'} .EXAMPLE - Get-nbExportTemplate myExportTemplate + Get-nbSite mySite #> -Function Get-nbExportTemplate { +Function Get-nbSite { [CmdletBinding(DefaultParameterSetName = 'query')] Param ( # Simple string based search @@ -3394,22 +3610,26 @@ Function Get-nbExportTemplate { [uri] $APIUrl ) - $forward = @{ - UnFlatten = $UnFlatten - } - if ($AdditionalParams) { - $forward += $AdditionalParams - } - if ($PSCmdlet.ParameterSetName -eq 'id') { - $forward['Resource'] = "extras/export-templates/$id" - } elseif ($PSCmdlet.ParameterSetName -eq 'query') { - $forward['Resource'] = "extras/export-templates" - $forward['Query'] = $Query - $forward['Search'] = $search - } - if ($APIUrl) { - $forward['APIUrl'] = $APIUrl + try { + $forward = @{ + UnFlatten = $UnFlatten + } + if ($AdditionalParams) { + $forward += $AdditionalParams + } + if ($PSCmdlet.ParameterSetName -eq 'id') { + $forward['Resource'] = "dcim/sites/$id" + } elseif ($PSCmdlet.ParameterSetName -eq 'query') { + $forward['Resource'] = "dcim/sites" + $forward['Query'] = $Query + $forward['Search'] = $search + } + if ($APIUrl) { + $forward['APIUrl'] = $APIUrl + } + Get-nbObject @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - Get-nbObject @forward } diff --git a/module/Public/New-nbObject.ps1 b/module/Public/New-nbObject.ps1 index 8a66846..89ec952 100644 --- a/module/Public/New-nbObject.ps1 +++ b/module/Public/New-nbObject.ps1 @@ -43,7 +43,7 @@ function New-nbObject { $Lookup, # you can specify properties as arguments to this command - [Parameter(Mandatory=$true)] + [Parameter(Mandatory = $true)] $Object, # Passthrough to invoke-nbapi @@ -62,25 +62,29 @@ function New-nbObject { [uri] $APIUrl ) - - $mapObject = @{custom_fields = @{}} - foreach ($property in $object.psobject.properties) { - $Name = $Property.name -replace '-' -replace ':' - $value = $Property.value - if ($name -in $lookup.keys) { - $value = ConvertTo-nbID -source $lookup[$name] -value $value - } - if ($name -in $CustomProperties) { - $mapObject.custom_fields[$name] = $value - } - elseif ($name -eq 'custom_fields') { - $mapObject.custom_fields += $value - } - else { - $mapObject[$name] = $value + try { + $mapObject = @{custom_fields = @{} } + foreach ($property in $object.psobject.properties) { + $Name = $Property.name -replace '-' -replace ':' + $value = $Property.value + if ($name -in $lookup.keys) { + $value = ConvertTo-nbID -source $lookup[$name] -value $value + } + if ($name -in $CustomProperties) { + $mapObject.custom_fields[$name] = $value + } + elseif ($name -eq 'custom_fields') { + $mapObject.custom_fields += $value + } + else { + $mapObject[$name] = $value + } } - } - $mapObject = New-Object -TypeName psobject -Property $mapObject + $mapObject = New-Object -TypeName psobject -Property $mapObject - Invoke-nbApi -Resource $Resource -HttpVerb POST -Body ($mapObject | ConvertTo-Json -Compress) + Invoke-nbApi -Resource $Resource -HttpVerb POST -Body ($mapObject | ConvertTo-Json -Compress) + } + catch { + $PSCmdlet.ThrowTerminatingError($_) + } } diff --git a/module/Public/New-nbx.ps1 b/module/Public/New-nbx.ps1 index 915ff1b..d023497 100644 --- a/module/Public/New-nbx.ps1 +++ b/module/Public/New-nbx.ps1 @@ -5,7 +5,7 @@ <# .SYNOPSIS - Creates a new Prefix in netbox + Creates a new VlanGroup in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -15,7 +15,7 @@ site='organization/sites' status='dcim/_choices' } - $Prefix = @{ + $VlanGroup = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -23,11 +23,11 @@ site = 'chicago' status = 'active' } - New-nbPrefix -lookup $lookup -object $Prefix + New-nbVlanGroup -lookup $lookup -object $VlanGroup #> -Function New-nbPrefix { +Function New-nbVlanGroup { Param ( - # Prefix to create + # VlanGroup to create [Parameter(Mandatory = $true)] $Object, @@ -41,17 +41,21 @@ Function New-nbPrefix { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'ipam/vlan-groups' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'ipam/prefixes' @forward } <# .SYNOPSIS - Creates a new ConsolePortTemplate in netbox + Creates a new ClusterGroup in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -61,7 +65,7 @@ Function New-nbPrefix { site='organization/sites' status='dcim/_choices' } - $ConsolePortTemplate = @{ + $ClusterGroup = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -69,11 +73,11 @@ Function New-nbPrefix { site = 'chicago' status = 'active' } - New-nbConsolePortTemplate -lookup $lookup -object $ConsolePortTemplate + New-nbClusterGroup -lookup $lookup -object $ClusterGroup #> -Function New-nbConsolePortTemplate { +Function New-nbClusterGroup { Param ( - # ConsolePortTemplate to create + # ClusterGroup to create [Parameter(Mandatory = $true)] $Object, @@ -87,17 +91,21 @@ Function New-nbConsolePortTemplate { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'virtualization/cluster-groups' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'dcim/console-port-templates' @forward } <# .SYNOPSIS - Creates a new Interface in netbox + Creates a new DeviceType in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -107,7 +115,7 @@ Function New-nbConsolePortTemplate { site='organization/sites' status='dcim/_choices' } - $Interface = @{ + $DeviceType = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -115,11 +123,11 @@ Function New-nbConsolePortTemplate { site = 'chicago' status = 'active' } - New-nbInterface -lookup $lookup -object $Interface + New-nbDeviceType -lookup $lookup -object $DeviceType #> -Function New-nbInterface { +Function New-nbDeviceType { Param ( - # Interface to create + # DeviceType to create [Parameter(Mandatory = $true)] $Object, @@ -133,17 +141,21 @@ Function New-nbInterface { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'dcim/device-types' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'dcim/interfaces' @forward } <# .SYNOPSIS - Creates a new PowerConnection in netbox + Creates a new PowerOutlet in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -153,7 +165,7 @@ Function New-nbInterface { site='organization/sites' status='dcim/_choices' } - $PowerConnection = @{ + $PowerOutlet = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -161,11 +173,11 @@ Function New-nbInterface { site = 'chicago' status = 'active' } - New-nbPowerConnection -lookup $lookup -object $PowerConnection + New-nbPowerOutlet -lookup $lookup -object $PowerOutlet #> -Function New-nbPowerConnection { +Function New-nbPowerOutlet { Param ( - # PowerConnection to create + # PowerOutlet to create [Parameter(Mandatory = $true)] $Object, @@ -179,12 +191,16 @@ Function New-nbPowerConnection { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'dcim/power-outlets' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'dcim/power-connections' @forward } <# @@ -225,17 +241,21 @@ Function New-nbConnectedDevice { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'dcim/connected-device' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'dcim/connected-device' @forward } <# .SYNOPSIS - Creates a new IpAddress in netbox + Creates a new Region in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -245,7 +265,7 @@ Function New-nbConnectedDevice { site='organization/sites' status='dcim/_choices' } - $IpAddress = @{ + $Region = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -253,11 +273,11 @@ Function New-nbConnectedDevice { site = 'chicago' status = 'active' } - New-nbIpAddress -lookup $lookup -object $IpAddress + New-nbRegion -lookup $lookup -object $Region #> -Function New-nbIpAddress { +Function New-nbRegion { Param ( - # IpAddress to create + # Region to create [Parameter(Mandatory = $true)] $Object, @@ -271,17 +291,21 @@ Function New-nbIpAddress { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'dcim/regions' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'ipam/ip-addresses' @forward } <# .SYNOPSIS - Creates a new Aggregate in netbox + Creates a new ConsoleServerPortTemplate in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -291,7 +315,7 @@ Function New-nbIpAddress { site='organization/sites' status='dcim/_choices' } - $Aggregate = @{ + $ConsoleServerPortTemplate = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -299,11 +323,11 @@ Function New-nbIpAddress { site = 'chicago' status = 'active' } - New-nbAggregate -lookup $lookup -object $Aggregate + New-nbConsoleServerPortTemplate -lookup $lookup -object $ConsoleServerPortTemplate #> -Function New-nbAggregate { +Function New-nbConsoleServerPortTemplate { Param ( - # Aggregate to create + # ConsoleServerPortTemplate to create [Parameter(Mandatory = $true)] $Object, @@ -317,17 +341,21 @@ Function New-nbAggregate { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'dcim/console-server-port-templates' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'ipam/aggregates' @forward } <# .SYNOPSIS - Creates a new PowerPortTemplate in netbox + Creates a new Aggregate in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -337,7 +365,7 @@ Function New-nbAggregate { site='organization/sites' status='dcim/_choices' } - $PowerPortTemplate = @{ + $Aggregate = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -345,11 +373,11 @@ Function New-nbAggregate { site = 'chicago' status = 'active' } - New-nbPowerPortTemplate -lookup $lookup -object $PowerPortTemplate + New-nbAggregate -lookup $lookup -object $Aggregate #> -Function New-nbPowerPortTemplate { +Function New-nbAggregate { Param ( - # PowerPortTemplate to create + # Aggregate to create [Parameter(Mandatory = $true)] $Object, @@ -363,17 +391,21 @@ Function New-nbPowerPortTemplate { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'ipam/aggregates' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'dcim/power-port-templates' @forward } <# .SYNOPSIS - Creates a new ImageAttachment in netbox + Creates a new ClusterType in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -383,7 +415,7 @@ Function New-nbPowerPortTemplate { site='organization/sites' status='dcim/_choices' } - $ImageAttachment = @{ + $ClusterType = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -391,11 +423,11 @@ Function New-nbPowerPortTemplate { site = 'chicago' status = 'active' } - New-nbImageAttachment -lookup $lookup -object $ImageAttachment + New-nbClusterType -lookup $lookup -object $ClusterType #> -Function New-nbImageAttachment { +Function New-nbClusterType { Param ( - # ImageAttachment to create + # ClusterType to create [Parameter(Mandatory = $true)] $Object, @@ -409,17 +441,21 @@ Function New-nbImageAttachment { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'virtualization/cluster-types' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'extras/image-attachments' @forward } <# .SYNOPSIS - Creates a new ConsoleServerPort in netbox + Creates a new Vlan in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -429,7 +465,7 @@ Function New-nbImageAttachment { site='organization/sites' status='dcim/_choices' } - $ConsoleServerPort = @{ + $Vlan = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -437,11 +473,11 @@ Function New-nbImageAttachment { site = 'chicago' status = 'active' } - New-nbConsoleServerPort -lookup $lookup -object $ConsoleServerPort + New-nbVlan -lookup $lookup -object $Vlan #> -Function New-nbConsoleServerPort { +Function New-nbVlan { Param ( - # ConsoleServerPort to create + # Vlan to create [Parameter(Mandatory = $true)] $Object, @@ -455,17 +491,21 @@ Function New-nbConsoleServerPort { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'ipam/vlans' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'dcim/console-server-ports' @forward } <# .SYNOPSIS - Creates a new InventoryItem in netbox + Creates a new Provider in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -475,7 +515,7 @@ Function New-nbConsoleServerPort { site='organization/sites' status='dcim/_choices' } - $InventoryItem = @{ + $Provider = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -483,11 +523,11 @@ Function New-nbConsoleServerPort { site = 'chicago' status = 'active' } - New-nbInventoryItem -lookup $lookup -object $InventoryItem + New-nbProvider -lookup $lookup -object $Provider #> -Function New-nbInventoryItem { +Function New-nbProvider { Param ( - # InventoryItem to create + # Provider to create [Parameter(Mandatory = $true)] $Object, @@ -501,17 +541,21 @@ Function New-nbInventoryItem { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'circuits/providers' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'dcim/inventory-items' @forward } <# .SYNOPSIS - Creates a new Service in netbox + Creates a new PowerConnection in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -521,7 +565,7 @@ Function New-nbInventoryItem { site='organization/sites' status='dcim/_choices' } - $Service = @{ + $PowerConnection = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -529,11 +573,11 @@ Function New-nbInventoryItem { site = 'chicago' status = 'active' } - New-nbService -lookup $lookup -object $Service + New-nbPowerConnection -lookup $lookup -object $PowerConnection #> -Function New-nbService { +Function New-nbPowerConnection { Param ( - # Service to create + # PowerConnection to create [Parameter(Mandatory = $true)] $Object, @@ -547,17 +591,21 @@ Function New-nbService { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'dcim/power-connections' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'ipam/services' @forward } <# .SYNOPSIS - Creates a new ConsoleServerPortTemplate in netbox + Creates a new ConsolePort in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -567,7 +615,7 @@ Function New-nbService { site='organization/sites' status='dcim/_choices' } - $ConsoleServerPortTemplate = @{ + $ConsolePort = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -575,11 +623,11 @@ Function New-nbService { site = 'chicago' status = 'active' } - New-nbConsoleServerPortTemplate -lookup $lookup -object $ConsoleServerPortTemplate + New-nbConsolePort -lookup $lookup -object $ConsolePort #> -Function New-nbConsoleServerPortTemplate { +Function New-nbConsolePort { Param ( - # ConsoleServerPortTemplate to create + # ConsolePort to create [Parameter(Mandatory = $true)] $Object, @@ -593,17 +641,21 @@ Function New-nbConsoleServerPortTemplate { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'dcim/console-ports' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'dcim/console-server-port-templates' @forward } <# .SYNOPSIS - Creates a new VirtualMachine in netbox + Creates a new VMInterface in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -613,7 +665,7 @@ Function New-nbConsoleServerPortTemplate { site='organization/sites' status='dcim/_choices' } - $VirtualMachine = @{ + $VMInterface = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -621,11 +673,11 @@ Function New-nbConsoleServerPortTemplate { site = 'chicago' status = 'active' } - New-nbVirtualMachine -lookup $lookup -object $VirtualMachine + New-nbVMInterface -lookup $lookup -object $VMInterface #> -Function New-nbVirtualMachine { +Function New-nbVMInterface { Param ( - # VirtualMachine to create + # VMInterface to create [Parameter(Mandatory = $true)] $Object, @@ -639,17 +691,21 @@ Function New-nbVirtualMachine { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'virtualization/interfaces' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'virtualization/virtual-machines' @forward } <# .SYNOPSIS - Creates a new Rir in netbox + Creates a new Platform in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -659,7 +715,7 @@ Function New-nbVirtualMachine { site='organization/sites' status='dcim/_choices' } - $Rir = @{ + $Platform = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -667,11 +723,11 @@ Function New-nbVirtualMachine { site = 'chicago' status = 'active' } - New-nbRir -lookup $lookup -object $Rir + New-nbPlatform -lookup $lookup -object $Platform #> -Function New-nbRir { +Function New-nbPlatform { Param ( - # Rir to create + # Platform to create [Parameter(Mandatory = $true)] $Object, @@ -685,17 +741,21 @@ Function New-nbRir { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'dcim/platforms' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'ipam/rirs' @forward } <# .SYNOPSIS - Creates a new Report in netbox + Creates a new Circuit in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -705,7 +765,7 @@ Function New-nbRir { site='organization/sites' status='dcim/_choices' } - $Report = @{ + $Circuit = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -713,11 +773,11 @@ Function New-nbRir { site = 'chicago' status = 'active' } - New-nbReport -lookup $lookup -object $Report + New-nbCircuit -lookup $lookup -object $Circuit #> -Function New-nbReport { +Function New-nbCircuit { Param ( - # Report to create + # Circuit to create [Parameter(Mandatory = $true)] $Object, @@ -731,17 +791,21 @@ Function New-nbReport { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'circuits/circuits' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'extras/reports' @forward } <# .SYNOPSIS - Creates a new TenantGroup in netbox + Creates a new RackReservation in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -751,7 +815,7 @@ Function New-nbReport { site='organization/sites' status='dcim/_choices' } - $TenantGroup = @{ + $RackReservation = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -759,11 +823,11 @@ Function New-nbReport { site = 'chicago' status = 'active' } - New-nbTenantGroup -lookup $lookup -object $TenantGroup + New-nbRackReservation -lookup $lookup -object $RackReservation #> -Function New-nbTenantGroup { +Function New-nbRackReservation { Param ( - # TenantGroup to create + # RackReservation to create [Parameter(Mandatory = $true)] $Object, @@ -777,17 +841,21 @@ Function New-nbTenantGroup { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'dcim/rack-reservations' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'tenancy/tenant-groups' @forward } <# .SYNOPSIS - Creates a new TopologyMap in netbox + Creates a new TenantGroup in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -797,7 +865,7 @@ Function New-nbTenantGroup { site='organization/sites' status='dcim/_choices' } - $TopologyMap = @{ + $TenantGroup = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -805,11 +873,11 @@ Function New-nbTenantGroup { site = 'chicago' status = 'active' } - New-nbTopologyMap -lookup $lookup -object $TopologyMap + New-nbTenantGroup -lookup $lookup -object $TenantGroup #> -Function New-nbTopologyMap { +Function New-nbTenantGroup { Param ( - # TopologyMap to create + # TenantGroup to create [Parameter(Mandatory = $true)] $Object, @@ -823,17 +891,21 @@ Function New-nbTopologyMap { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'tenancy/tenant-groups' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'extras/topology-maps' @forward } <# .SYNOPSIS - Creates a new RackGroup in netbox + Creates a new Devicebay in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -843,7 +915,7 @@ Function New-nbTopologyMap { site='organization/sites' status='dcim/_choices' } - $RackGroup = @{ + $Devicebay = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -851,11 +923,11 @@ Function New-nbTopologyMap { site = 'chicago' status = 'active' } - New-nbRackGroup -lookup $lookup -object $RackGroup + New-nbDevicebay -lookup $lookup -object $Devicebay #> -Function New-nbRackGroup { +Function New-nbDevicebay { Param ( - # RackGroup to create + # Devicebay to create [Parameter(Mandatory = $true)] $Object, @@ -869,17 +941,21 @@ Function New-nbRackGroup { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'dcim/device-bays' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'dcim/rack-groups' @forward } <# .SYNOPSIS - Creates a new Provider in netbox + Creates a new Rir in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -889,7 +965,7 @@ Function New-nbRackGroup { site='organization/sites' status='dcim/_choices' } - $Provider = @{ + $Rir = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -897,11 +973,11 @@ Function New-nbRackGroup { site = 'chicago' status = 'active' } - New-nbProvider -lookup $lookup -object $Provider + New-nbRir -lookup $lookup -object $Rir #> -Function New-nbProvider { +Function New-nbRir { Param ( - # Provider to create + # Rir to create [Parameter(Mandatory = $true)] $Object, @@ -915,17 +991,21 @@ Function New-nbProvider { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'ipam/rirs' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'circuits/providers' @forward } <# .SYNOPSIS - Creates a new RackReservation in netbox + Creates a new DevicebayTemplate in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -935,7 +1015,7 @@ Function New-nbProvider { site='organization/sites' status='dcim/_choices' } - $RackReservation = @{ + $DevicebayTemplate = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -943,11 +1023,11 @@ Function New-nbProvider { site = 'chicago' status = 'active' } - New-nbRackReservation -lookup $lookup -object $RackReservation + New-nbDevicebayTemplate -lookup $lookup -object $DevicebayTemplate #> -Function New-nbRackReservation { +Function New-nbDevicebayTemplate { Param ( - # RackReservation to create + # DevicebayTemplate to create [Parameter(Mandatory = $true)] $Object, @@ -961,17 +1041,21 @@ Function New-nbRackReservation { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'dcim/device-bay-templates' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'dcim/rack-reservations' @forward } <# .SYNOPSIS - Creates a new PowerOutletTemplate in netbox + Creates a new Graph in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -981,7 +1065,7 @@ Function New-nbRackReservation { site='organization/sites' status='dcim/_choices' } - $PowerOutletTemplate = @{ + $Graph = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -989,11 +1073,11 @@ Function New-nbRackReservation { site = 'chicago' status = 'active' } - New-nbPowerOutletTemplate -lookup $lookup -object $PowerOutletTemplate + New-nbGraph -lookup $lookup -object $Graph #> -Function New-nbPowerOutletTemplate { +Function New-nbGraph { Param ( - # PowerOutletTemplate to create + # Graph to create [Parameter(Mandatory = $true)] $Object, @@ -1007,17 +1091,21 @@ Function New-nbPowerOutletTemplate { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'extras/graphs' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'dcim/power-outlet-templates' @forward } <# .SYNOPSIS - Creates a new PowerOutlet in netbox + Creates a new Interface in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1027,7 +1115,7 @@ Function New-nbPowerOutletTemplate { site='organization/sites' status='dcim/_choices' } - $PowerOutlet = @{ + $Interface = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1035,11 +1123,11 @@ Function New-nbPowerOutletTemplate { site = 'chicago' status = 'active' } - New-nbPowerOutlet -lookup $lookup -object $PowerOutlet + New-nbInterface -lookup $lookup -object $Interface #> -Function New-nbPowerOutlet { +Function New-nbInterface { Param ( - # PowerOutlet to create + # Interface to create [Parameter(Mandatory = $true)] $Object, @@ -1053,17 +1141,21 @@ Function New-nbPowerOutlet { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'dcim/interfaces' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'dcim/power-outlets' @forward } <# .SYNOPSIS - Creates a new Circuit in netbox + Creates a new InterfaceConnection in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1073,7 +1165,7 @@ Function New-nbPowerOutlet { site='organization/sites' status='dcim/_choices' } - $Circuit = @{ + $InterfaceConnection = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1081,11 +1173,11 @@ Function New-nbPowerOutlet { site = 'chicago' status = 'active' } - New-nbCircuit -lookup $lookup -object $Circuit + New-nbInterfaceConnection -lookup $lookup -object $InterfaceConnection #> -Function New-nbCircuit { +Function New-nbInterfaceConnection { Param ( - # Circuit to create + # InterfaceConnection to create [Parameter(Mandatory = $true)] $Object, @@ -1099,17 +1191,21 @@ Function New-nbCircuit { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'dcim/interface-connections' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'circuits/circuits' @forward } <# .SYNOPSIS - Creates a new Graph in netbox + Creates a new Role in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1119,7 +1215,7 @@ Function New-nbCircuit { site='organization/sites' status='dcim/_choices' } - $Graph = @{ + $Role = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1127,11 +1223,11 @@ Function New-nbCircuit { site = 'chicago' status = 'active' } - New-nbGraph -lookup $lookup -object $Graph + New-nbRole -lookup $lookup -object $Role #> -Function New-nbGraph { +Function New-nbRole { Param ( - # Graph to create + # Role to create [Parameter(Mandatory = $true)] $Object, @@ -1145,17 +1241,21 @@ Function New-nbGraph { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'ipam/roles' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'extras/graphs' @forward } <# .SYNOPSIS - Creates a new Device in netbox + Creates a new ImageAttachment in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1165,7 +1265,7 @@ Function New-nbGraph { site='organization/sites' status='dcim/_choices' } - $Device = @{ + $ImageAttachment = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1173,11 +1273,11 @@ Function New-nbGraph { site = 'chicago' status = 'active' } - New-nbDevice -lookup $lookup -object $Device + New-nbImageAttachment -lookup $lookup -object $ImageAttachment #> -Function New-nbDevice { +Function New-nbImageAttachment { Param ( - # Device to create + # ImageAttachment to create [Parameter(Mandatory = $true)] $Object, @@ -1191,17 +1291,21 @@ Function New-nbDevice { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'extras/image-attachments' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'dcim/devices' @forward } <# .SYNOPSIS - Creates a new VirtualChassis in netbox + Creates a new Rack in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1211,7 +1315,7 @@ Function New-nbDevice { site='organization/sites' status='dcim/_choices' } - $VirtualChassis = @{ + $Rack = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1219,11 +1323,11 @@ Function New-nbDevice { site = 'chicago' status = 'active' } - New-nbVirtualChassis -lookup $lookup -object $VirtualChassis + New-nbRack -lookup $lookup -object $Rack #> -Function New-nbVirtualChassis { +Function New-nbRack { Param ( - # VirtualChassis to create + # Rack to create [Parameter(Mandatory = $true)] $Object, @@ -1237,17 +1341,21 @@ Function New-nbVirtualChassis { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'dcim/racks' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'dcim/virtual-chassis' @forward } <# .SYNOPSIS - Creates a new DevicebayTemplate in netbox + Creates a new ConsolePortTemplate in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1257,7 +1365,7 @@ Function New-nbVirtualChassis { site='organization/sites' status='dcim/_choices' } - $DevicebayTemplate = @{ + $ConsolePortTemplate = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1265,11 +1373,11 @@ Function New-nbVirtualChassis { site = 'chicago' status = 'active' } - New-nbDevicebayTemplate -lookup $lookup -object $DevicebayTemplate + New-nbConsolePortTemplate -lookup $lookup -object $ConsolePortTemplate #> -Function New-nbDevicebayTemplate { +Function New-nbConsolePortTemplate { Param ( - # DevicebayTemplate to create + # ConsolePortTemplate to create [Parameter(Mandatory = $true)] $Object, @@ -1283,17 +1391,21 @@ Function New-nbDevicebayTemplate { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'dcim/console-port-templates' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'dcim/device-bay-templates' @forward } <# .SYNOPSIS - Creates a new ConsoleConnection in netbox + Creates a new InterfaceTemplate in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1303,7 +1415,7 @@ Function New-nbDevicebayTemplate { site='organization/sites' status='dcim/_choices' } - $ConsoleConnection = @{ + $InterfaceTemplate = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1311,11 +1423,11 @@ Function New-nbDevicebayTemplate { site = 'chicago' status = 'active' } - New-nbConsoleConnection -lookup $lookup -object $ConsoleConnection + New-nbInterfaceTemplate -lookup $lookup -object $InterfaceTemplate #> -Function New-nbConsoleConnection { +Function New-nbInterfaceTemplate { Param ( - # ConsoleConnection to create + # InterfaceTemplate to create [Parameter(Mandatory = $true)] $Object, @@ -1329,17 +1441,21 @@ Function New-nbConsoleConnection { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'dcim/interface-templates' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'dcim/console-connections' @forward } <# .SYNOPSIS - Creates a new RackRole in netbox + Creates a new ExportTemplate in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1349,7 +1465,7 @@ Function New-nbConsoleConnection { site='organization/sites' status='dcim/_choices' } - $RackRole = @{ + $ExportTemplate = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1357,11 +1473,11 @@ Function New-nbConsoleConnection { site = 'chicago' status = 'active' } - New-nbRackRole -lookup $lookup -object $RackRole + New-nbExportTemplate -lookup $lookup -object $ExportTemplate #> -Function New-nbRackRole { +Function New-nbExportTemplate { Param ( - # RackRole to create + # ExportTemplate to create [Parameter(Mandatory = $true)] $Object, @@ -1375,17 +1491,21 @@ Function New-nbRackRole { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'extras/export-templates' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'dcim/rack-roles' @forward } <# .SYNOPSIS - Creates a new Platform in netbox + Creates a new Cluster in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1395,7 +1515,7 @@ Function New-nbRackRole { site='organization/sites' status='dcim/_choices' } - $Platform = @{ + $Cluster = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1403,11 +1523,11 @@ Function New-nbRackRole { site = 'chicago' status = 'active' } - New-nbPlatform -lookup $lookup -object $Platform + New-nbCluster -lookup $lookup -object $Cluster #> -Function New-nbPlatform { +Function New-nbCluster { Param ( - # Platform to create + # Cluster to create [Parameter(Mandatory = $true)] $Object, @@ -1421,17 +1541,21 @@ Function New-nbPlatform { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'virtualization/clusters' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'dcim/platforms' @forward } <# .SYNOPSIS - Creates a new Vlan in netbox + Creates a new Service in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1441,7 +1565,7 @@ Function New-nbPlatform { site='organization/sites' status='dcim/_choices' } - $Vlan = @{ + $Service = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1449,11 +1573,11 @@ Function New-nbPlatform { site = 'chicago' status = 'active' } - New-nbVlan -lookup $lookup -object $Vlan + New-nbService -lookup $lookup -object $Service #> -Function New-nbVlan { +Function New-nbService { Param ( - # Vlan to create + # Service to create [Parameter(Mandatory = $true)] $Object, @@ -1467,17 +1591,21 @@ Function New-nbVlan { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'ipam/services' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'ipam/vlans' @forward } <# .SYNOPSIS - Creates a new RecentActivity in netbox + Creates a new RackRole in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1487,7 +1615,7 @@ Function New-nbVlan { site='organization/sites' status='dcim/_choices' } - $RecentActivity = @{ + $RackRole = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1495,11 +1623,11 @@ Function New-nbVlan { site = 'chicago' status = 'active' } - New-nbRecentActivity -lookup $lookup -object $RecentActivity + New-nbRackRole -lookup $lookup -object $RackRole #> -Function New-nbRecentActivity { +Function New-nbRackRole { Param ( - # RecentActivity to create + # RackRole to create [Parameter(Mandatory = $true)] $Object, @@ -1513,17 +1641,21 @@ Function New-nbRecentActivity { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'dcim/rack-roles' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'extras/recent-activity' @forward } <# .SYNOPSIS - Creates a new Region in netbox + Creates a new CircuitType in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1533,7 +1665,7 @@ Function New-nbRecentActivity { site='organization/sites' status='dcim/_choices' } - $Region = @{ + $CircuitType = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1541,11 +1673,11 @@ Function New-nbRecentActivity { site = 'chicago' status = 'active' } - New-nbRegion -lookup $lookup -object $Region + New-nbCircuitType -lookup $lookup -object $CircuitType #> -Function New-nbRegion { +Function New-nbCircuitType { Param ( - # Region to create + # CircuitType to create [Parameter(Mandatory = $true)] $Object, @@ -1559,17 +1691,21 @@ Function New-nbRegion { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'circuits/circuit-types' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'dcim/regions' @forward } <# .SYNOPSIS - Creates a new Manufacturer in netbox + Creates a new Report in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1579,7 +1715,7 @@ Function New-nbRegion { site='organization/sites' status='dcim/_choices' } - $Manufacturer = @{ + $Report = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1587,11 +1723,11 @@ Function New-nbRegion { site = 'chicago' status = 'active' } - New-nbManufacturer -lookup $lookup -object $Manufacturer + New-nbReport -lookup $lookup -object $Report #> -Function New-nbManufacturer { +Function New-nbReport { Param ( - # Manufacturer to create + # Report to create [Parameter(Mandatory = $true)] $Object, @@ -1605,17 +1741,21 @@ Function New-nbManufacturer { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'extras/reports' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'dcim/manufacturers' @forward } <# .SYNOPSIS - Creates a new VlanGroup in netbox + Creates a new Manufacturer in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1625,7 +1765,7 @@ Function New-nbManufacturer { site='organization/sites' status='dcim/_choices' } - $VlanGroup = @{ + $Manufacturer = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1633,11 +1773,11 @@ Function New-nbManufacturer { site = 'chicago' status = 'active' } - New-nbVlanGroup -lookup $lookup -object $VlanGroup + New-nbManufacturer -lookup $lookup -object $Manufacturer #> -Function New-nbVlanGroup { +Function New-nbManufacturer { Param ( - # VlanGroup to create + # Manufacturer to create [Parameter(Mandatory = $true)] $Object, @@ -1651,17 +1791,21 @@ Function New-nbVlanGroup { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'dcim/manufacturers' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'ipam/vlan-groups' @forward } <# .SYNOPSIS - Creates a new Tenant in netbox + Creates a new RackGroup in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1671,7 +1815,7 @@ Function New-nbVlanGroup { site='organization/sites' status='dcim/_choices' } - $Tenant = @{ + $RackGroup = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1679,11 +1823,11 @@ Function New-nbVlanGroup { site = 'chicago' status = 'active' } - New-nbTenant -lookup $lookup -object $Tenant + New-nbRackGroup -lookup $lookup -object $RackGroup #> -Function New-nbTenant { +Function New-nbRackGroup { Param ( - # Tenant to create + # RackGroup to create [Parameter(Mandatory = $true)] $Object, @@ -1697,17 +1841,21 @@ Function New-nbTenant { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'dcim/rack-groups' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'tenancy/tenants' @forward } <# .SYNOPSIS - Creates a new DeviceType in netbox + Creates a new IpAddress in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1717,7 +1865,7 @@ Function New-nbTenant { site='organization/sites' status='dcim/_choices' } - $DeviceType = @{ + $IpAddress = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1725,11 +1873,11 @@ Function New-nbTenant { site = 'chicago' status = 'active' } - New-nbDeviceType -lookup $lookup -object $DeviceType + New-nbIpAddress -lookup $lookup -object $IpAddress #> -Function New-nbDeviceType { +Function New-nbIpAddress { Param ( - # DeviceType to create + # IpAddress to create [Parameter(Mandatory = $true)] $Object, @@ -1743,17 +1891,21 @@ Function New-nbDeviceType { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'ipam/ip-addresses' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'dcim/device-types' @forward } <# .SYNOPSIS - Creates a new CircuitTermination in netbox + Creates a new Vrf in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1763,7 +1915,7 @@ Function New-nbDeviceType { site='organization/sites' status='dcim/_choices' } - $CircuitTermination = @{ + $Vrf = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1771,11 +1923,11 @@ Function New-nbDeviceType { site = 'chicago' status = 'active' } - New-nbCircuitTermination -lookup $lookup -object $CircuitTermination + New-nbVrf -lookup $lookup -object $Vrf #> -Function New-nbCircuitTermination { +Function New-nbVrf { Param ( - # CircuitTermination to create + # Vrf to create [Parameter(Mandatory = $true)] $Object, @@ -1789,17 +1941,21 @@ Function New-nbCircuitTermination { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'ipam/vrfs' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'circuits/circuit-terminations' @forward } <# .SYNOPSIS - Creates a new ClusterType in netbox + Creates a new Device in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1809,7 +1965,7 @@ Function New-nbCircuitTermination { site='organization/sites' status='dcim/_choices' } - $ClusterType = @{ + $Device = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1817,11 +1973,11 @@ Function New-nbCircuitTermination { site = 'chicago' status = 'active' } - New-nbClusterType -lookup $lookup -object $ClusterType + New-nbDevice -lookup $lookup -object $Device #> -Function New-nbClusterType { +Function New-nbDevice { Param ( - # ClusterType to create + # Device to create [Parameter(Mandatory = $true)] $Object, @@ -1835,17 +1991,21 @@ Function New-nbClusterType { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'dcim/devices' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'virtualization/cluster-types' @forward } <# .SYNOPSIS - Creates a new PowerPort in netbox + Creates a new Tenant in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1855,7 +2015,7 @@ Function New-nbClusterType { site='organization/sites' status='dcim/_choices' } - $PowerPort = @{ + $Tenant = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1863,11 +2023,11 @@ Function New-nbClusterType { site = 'chicago' status = 'active' } - New-nbPowerPort -lookup $lookup -object $PowerPort + New-nbTenant -lookup $lookup -object $Tenant #> -Function New-nbPowerPort { +Function New-nbTenant { Param ( - # PowerPort to create + # Tenant to create [Parameter(Mandatory = $true)] $Object, @@ -1881,17 +2041,21 @@ Function New-nbPowerPort { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'tenancy/tenants' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'dcim/power-ports' @forward } <# .SYNOPSIS - Creates a new Role in netbox + Creates a new PowerOutletTemplate in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1901,7 +2065,7 @@ Function New-nbPowerPort { site='organization/sites' status='dcim/_choices' } - $Role = @{ + $PowerOutletTemplate = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1909,11 +2073,11 @@ Function New-nbPowerPort { site = 'chicago' status = 'active' } - New-nbRole -lookup $lookup -object $Role + New-nbPowerOutletTemplate -lookup $lookup -object $PowerOutletTemplate #> -Function New-nbRole { +Function New-nbPowerOutletTemplate { Param ( - # Role to create + # PowerOutletTemplate to create [Parameter(Mandatory = $true)] $Object, @@ -1927,17 +2091,21 @@ Function New-nbRole { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'dcim/power-outlet-templates' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'ipam/roles' @forward } <# .SYNOPSIS - Creates a new Vrf in netbox + Creates a new InventoryItem in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1947,7 +2115,7 @@ Function New-nbRole { site='organization/sites' status='dcim/_choices' } - $Vrf = @{ + $InventoryItem = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1955,11 +2123,11 @@ Function New-nbRole { site = 'chicago' status = 'active' } - New-nbVrf -lookup $lookup -object $Vrf + New-nbInventoryItem -lookup $lookup -object $InventoryItem #> -Function New-nbVrf { +Function New-nbInventoryItem { Param ( - # Vrf to create + # InventoryItem to create [Parameter(Mandatory = $true)] $Object, @@ -1973,17 +2141,21 @@ Function New-nbVrf { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'dcim/inventory-items' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'ipam/vrfs' @forward } <# .SYNOPSIS - Creates a new Rack in netbox + Creates a new ConsoleServerPort in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1993,7 +2165,7 @@ Function New-nbVrf { site='organization/sites' status='dcim/_choices' } - $Rack = @{ + $ConsoleServerPort = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -2001,11 +2173,11 @@ Function New-nbVrf { site = 'chicago' status = 'active' } - New-nbRack -lookup $lookup -object $Rack + New-nbConsoleServerPort -lookup $lookup -object $ConsoleServerPort #> -Function New-nbRack { +Function New-nbConsoleServerPort { Param ( - # Rack to create + # ConsoleServerPort to create [Parameter(Mandatory = $true)] $Object, @@ -2019,17 +2191,21 @@ Function New-nbRack { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'dcim/console-server-ports' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'dcim/racks' @forward } <# .SYNOPSIS - Creates a new Cluster in netbox + Creates a new VirtualChassis in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -2039,7 +2215,7 @@ Function New-nbRack { site='organization/sites' status='dcim/_choices' } - $Cluster = @{ + $VirtualChassis = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -2047,11 +2223,11 @@ Function New-nbRack { site = 'chicago' status = 'active' } - New-nbCluster -lookup $lookup -object $Cluster + New-nbVirtualChassis -lookup $lookup -object $VirtualChassis #> -Function New-nbCluster { +Function New-nbVirtualChassis { Param ( - # Cluster to create + # VirtualChassis to create [Parameter(Mandatory = $true)] $Object, @@ -2065,17 +2241,21 @@ Function New-nbCluster { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'dcim/virtual-chassis' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'virtualization/clusters' @forward } <# .SYNOPSIS - Creates a new Site in netbox + Creates a new VirtualMachine in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -2085,7 +2265,7 @@ Function New-nbCluster { site='organization/sites' status='dcim/_choices' } - $Site = @{ + $VirtualMachine = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -2093,11 +2273,11 @@ Function New-nbCluster { site = 'chicago' status = 'active' } - New-nbSite -lookup $lookup -object $Site + New-nbVirtualMachine -lookup $lookup -object $VirtualMachine #> -Function New-nbSite { +Function New-nbVirtualMachine { Param ( - # Site to create + # VirtualMachine to create [Parameter(Mandatory = $true)] $Object, @@ -2111,17 +2291,21 @@ Function New-nbSite { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'virtualization/virtual-machines' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'dcim/sites' @forward } <# .SYNOPSIS - Creates a new ClusterGroup in netbox + Creates a new PowerPort in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -2131,7 +2315,7 @@ Function New-nbSite { site='organization/sites' status='dcim/_choices' } - $ClusterGroup = @{ + $PowerPort = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -2139,11 +2323,11 @@ Function New-nbSite { site = 'chicago' status = 'active' } - New-nbClusterGroup -lookup $lookup -object $ClusterGroup + New-nbPowerPort -lookup $lookup -object $PowerPort #> -Function New-nbClusterGroup { +Function New-nbPowerPort { Param ( - # ClusterGroup to create + # PowerPort to create [Parameter(Mandatory = $true)] $Object, @@ -2157,17 +2341,21 @@ Function New-nbClusterGroup { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'dcim/power-ports' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'virtualization/cluster-groups' @forward } <# .SYNOPSIS - Creates a new InterfaceConnection in netbox + Creates a new PowerPortTemplate in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -2177,7 +2365,7 @@ Function New-nbClusterGroup { site='organization/sites' status='dcim/_choices' } - $InterfaceConnection = @{ + $PowerPortTemplate = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -2185,11 +2373,11 @@ Function New-nbClusterGroup { site = 'chicago' status = 'active' } - New-nbInterfaceConnection -lookup $lookup -object $InterfaceConnection + New-nbPowerPortTemplate -lookup $lookup -object $PowerPortTemplate #> -Function New-nbInterfaceConnection { +Function New-nbPowerPortTemplate { Param ( - # InterfaceConnection to create + # PowerPortTemplate to create [Parameter(Mandatory = $true)] $Object, @@ -2203,17 +2391,21 @@ Function New-nbInterfaceConnection { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'dcim/power-port-templates' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'dcim/interface-connections' @forward } <# .SYNOPSIS - Creates a new CircuitType in netbox + Creates a new ConsoleConnection in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -2223,7 +2415,7 @@ Function New-nbInterfaceConnection { site='organization/sites' status='dcim/_choices' } - $CircuitType = @{ + $ConsoleConnection = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -2231,11 +2423,11 @@ Function New-nbInterfaceConnection { site = 'chicago' status = 'active' } - New-nbCircuitType -lookup $lookup -object $CircuitType + New-nbConsoleConnection -lookup $lookup -object $ConsoleConnection #> -Function New-nbCircuitType { +Function New-nbConsoleConnection { Param ( - # CircuitType to create + # ConsoleConnection to create [Parameter(Mandatory = $true)] $Object, @@ -2249,17 +2441,21 @@ Function New-nbCircuitType { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'dcim/console-connections' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'circuits/circuit-types' @forward } <# .SYNOPSIS - Creates a new DeviceRole in netbox + Creates a new TopologyMap in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -2269,7 +2465,7 @@ Function New-nbCircuitType { site='organization/sites' status='dcim/_choices' } - $DeviceRole = @{ + $TopologyMap = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -2277,11 +2473,11 @@ Function New-nbCircuitType { site = 'chicago' status = 'active' } - New-nbDeviceRole -lookup $lookup -object $DeviceRole + New-nbTopologyMap -lookup $lookup -object $TopologyMap #> -Function New-nbDeviceRole { +Function New-nbTopologyMap { Param ( - # DeviceRole to create + # TopologyMap to create [Parameter(Mandatory = $true)] $Object, @@ -2295,17 +2491,21 @@ Function New-nbDeviceRole { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'extras/topology-maps' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'dcim/device-roles' @forward } <# .SYNOPSIS - Creates a new VMInterface in netbox + Creates a new CircuitTermination in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -2315,7 +2515,7 @@ Function New-nbDeviceRole { site='organization/sites' status='dcim/_choices' } - $VMInterface = @{ + $CircuitTermination = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -2323,11 +2523,11 @@ Function New-nbDeviceRole { site = 'chicago' status = 'active' } - New-nbVMInterface -lookup $lookup -object $VMInterface + New-nbCircuitTermination -lookup $lookup -object $CircuitTermination #> -Function New-nbVMInterface { +Function New-nbCircuitTermination { Param ( - # VMInterface to create + # CircuitTermination to create [Parameter(Mandatory = $true)] $Object, @@ -2341,17 +2541,21 @@ Function New-nbVMInterface { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'circuits/circuit-terminations' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'virtualization/interfaces' @forward } <# .SYNOPSIS - Creates a new ConsolePort in netbox + Creates a new RecentActivity in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -2361,7 +2565,7 @@ Function New-nbVMInterface { site='organization/sites' status='dcim/_choices' } - $ConsolePort = @{ + $RecentActivity = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -2369,11 +2573,11 @@ Function New-nbVMInterface { site = 'chicago' status = 'active' } - New-nbConsolePort -lookup $lookup -object $ConsolePort + New-nbRecentActivity -lookup $lookup -object $RecentActivity #> -Function New-nbConsolePort { +Function New-nbRecentActivity { Param ( - # ConsolePort to create + # RecentActivity to create [Parameter(Mandatory = $true)] $Object, @@ -2387,17 +2591,21 @@ Function New-nbConsolePort { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'extras/recent-activity' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'dcim/console-ports' @forward } <# .SYNOPSIS - Creates a new Devicebay in netbox + Creates a new Prefix in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -2407,7 +2615,7 @@ Function New-nbConsolePort { site='organization/sites' status='dcim/_choices' } - $Devicebay = @{ + $Prefix = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -2415,11 +2623,11 @@ Function New-nbConsolePort { site = 'chicago' status = 'active' } - New-nbDevicebay -lookup $lookup -object $Devicebay + New-nbPrefix -lookup $lookup -object $Prefix #> -Function New-nbDevicebay { +Function New-nbPrefix { Param ( - # Devicebay to create + # Prefix to create [Parameter(Mandatory = $true)] $Object, @@ -2433,17 +2641,21 @@ Function New-nbDevicebay { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'ipam/prefixes' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'dcim/device-bays' @forward } <# .SYNOPSIS - Creates a new InterfaceTemplate in netbox + Creates a new DeviceRole in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -2453,7 +2665,7 @@ Function New-nbDevicebay { site='organization/sites' status='dcim/_choices' } - $InterfaceTemplate = @{ + $DeviceRole = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -2461,11 +2673,11 @@ Function New-nbDevicebay { site = 'chicago' status = 'active' } - New-nbInterfaceTemplate -lookup $lookup -object $InterfaceTemplate + New-nbDeviceRole -lookup $lookup -object $DeviceRole #> -Function New-nbInterfaceTemplate { +Function New-nbDeviceRole { Param ( - # InterfaceTemplate to create + # DeviceRole to create [Parameter(Mandatory = $true)] $Object, @@ -2479,17 +2691,21 @@ Function New-nbInterfaceTemplate { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'dcim/device-roles' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'dcim/interface-templates' @forward } <# .SYNOPSIS - Creates a new ExportTemplate in netbox + Creates a new Site in netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -2499,7 +2715,7 @@ Function New-nbInterfaceTemplate { site='organization/sites' status='dcim/_choices' } - $ExportTemplate = @{ + $Site = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -2507,11 +2723,11 @@ Function New-nbInterfaceTemplate { site = 'chicago' status = 'active' } - New-nbExportTemplate -lookup $lookup -object $ExportTemplate + New-nbSite -lookup $lookup -object $Site #> -Function New-nbExportTemplate { +Function New-nbSite { Param ( - # ExportTemplate to create + # Site to create [Parameter(Mandatory = $true)] $Object, @@ -2525,11 +2741,15 @@ Function New-nbExportTemplate { [hashtable] $Lookup ) - $forward = @{ - Object=$Object - CustomProperties=$CustomProperties - Lookup=$lookup + try { + $forward = @{ + Object=$Object + CustomProperties=$CustomProperties + Lookup=$lookup + } + New-nbObject -Resource 'dcim/sites' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) } - New-nbObject -Resource 'extras/export-templates' @forward } diff --git a/module/Public/Remove-nbObject.ps1 b/module/Public/Remove-nbObject.ps1 index 0bb0c7c..9fb27b5 100644 --- a/module/Public/Remove-nbObject.ps1 +++ b/module/Public/Remove-nbObject.ps1 @@ -25,8 +25,11 @@ function Remove-nbObject { $Resource ) - process { - Invoke-nbApi -Resource "$Resource/$id" -HttpVerb Delete + try { + Invoke-nbApi -Resource "$Resource/$id" -HttpVerb Delete + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } } diff --git a/module/Public/Remove-nbx.ps1 b/module/Public/Remove-nbx.ps1 index b85d594..8a4ff13 100644 --- a/module/Public/Remove-nbx.ps1 +++ b/module/Public/Remove-nbx.ps1 @@ -5,94 +5,110 @@ <# .SYNOPSIS - Deletes a Prefix in Netbox + Deletes a VlanGroup in Netbox .DESCRIPTION - Deletes a netbox Prefix by ID or via the pipeline. + Deletes a netbox VlanGroup by ID or via the pipeline. .EXAMPLE - # Remove the Prefix by id - Remove-nbPrefix -id 1 + # Remove the VlanGroup by id + Remove-nbVlanGroup -id 1 .EXAMPLE - #Remove Prefix returned from a get-nbPrefix - Get-NbPrefix -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbPrefix -Resource 'virtualization/virtual-machines' + #Remove VlanGroup returned from a get-nbVlanGroup + Get-NbVlanGroup -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbVlanGroup -Resource 'virtualization/virtual-machines' #> -Function Remove-nbPrefix { +Function Remove-nbVlanGroup { Param ( - # ID of the Prefix to delete + # ID of the VlanGroup to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'ipam/prefixes' -id $id + try { + Remove-nbObject -Resource 'ipam/vlan-groups' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a ConsolePortTemplate in Netbox + Deletes a ClusterGroup in Netbox .DESCRIPTION - Deletes a netbox ConsolePortTemplate by ID or via the pipeline. + Deletes a netbox ClusterGroup by ID or via the pipeline. .EXAMPLE - # Remove the ConsolePortTemplate by id - Remove-nbConsolePortTemplate -id 1 + # Remove the ClusterGroup by id + Remove-nbClusterGroup -id 1 .EXAMPLE - #Remove ConsolePortTemplate returned from a get-nbConsolePortTemplate - Get-NbConsolePortTemplate -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbConsolePortTemplate -Resource 'virtualization/virtual-machines' + #Remove ClusterGroup returned from a get-nbClusterGroup + Get-NbClusterGroup -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbClusterGroup -Resource 'virtualization/virtual-machines' #> -Function Remove-nbConsolePortTemplate { +Function Remove-nbClusterGroup { Param ( - # ID of the ConsolePortTemplate to delete + # ID of the ClusterGroup to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'dcim/console-port-templates' -id $id + try { + Remove-nbObject -Resource 'virtualization/cluster-groups' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a Interface in Netbox + Deletes a DeviceType in Netbox .DESCRIPTION - Deletes a netbox Interface by ID or via the pipeline. + Deletes a netbox DeviceType by ID or via the pipeline. .EXAMPLE - # Remove the Interface by id - Remove-nbInterface -id 1 + # Remove the DeviceType by id + Remove-nbDeviceType -id 1 .EXAMPLE - #Remove Interface returned from a get-nbInterface - Get-NbInterface -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbInterface -Resource 'virtualization/virtual-machines' + #Remove DeviceType returned from a get-nbDeviceType + Get-NbDeviceType -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbDeviceType -Resource 'virtualization/virtual-machines' #> -Function Remove-nbInterface { +Function Remove-nbDeviceType { Param ( - # ID of the Interface to delete + # ID of the DeviceType to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'dcim/interfaces' -id $id + try { + Remove-nbObject -Resource 'dcim/device-types' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a PowerConnection in Netbox + Deletes a PowerOutlet in Netbox .DESCRIPTION - Deletes a netbox PowerConnection by ID or via the pipeline. + Deletes a netbox PowerOutlet by ID or via the pipeline. .EXAMPLE - # Remove the PowerConnection by id - Remove-nbPowerConnection -id 1 + # Remove the PowerOutlet by id + Remove-nbPowerOutlet -id 1 .EXAMPLE - #Remove PowerConnection returned from a get-nbPowerConnection - Get-NbPowerConnection -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbPowerConnection -Resource 'virtualization/virtual-machines' + #Remove PowerOutlet returned from a get-nbPowerOutlet + Get-NbPowerOutlet -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbPowerOutlet -Resource 'virtualization/virtual-machines' #> -Function Remove-nbPowerConnection { +Function Remove-nbPowerOutlet { Param ( - # ID of the PowerConnection to delete + # ID of the PowerOutlet to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'dcim/power-connections' -id $id + try { + Remove-nbObject -Resource 'dcim/power-outlets' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# @@ -115,30 +131,65 @@ Function Remove-nbConnectedDevice { [Int] $Id ) - Remove-nbObject -Resource 'dcim/connected-device' -id $id + try { + Remove-nbObject -Resource 'dcim/connected-device' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a IpAddress in Netbox + Deletes a Region in Netbox .DESCRIPTION - Deletes a netbox IpAddress by ID or via the pipeline. + Deletes a netbox Region by ID or via the pipeline. .EXAMPLE - # Remove the IpAddress by id - Remove-nbIpAddress -id 1 + # Remove the Region by id + Remove-nbRegion -id 1 .EXAMPLE - #Remove IpAddress returned from a get-nbIpAddress - Get-NbIpAddress -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbIpAddress -Resource 'virtualization/virtual-machines' + #Remove Region returned from a get-nbRegion + Get-NbRegion -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbRegion -Resource 'virtualization/virtual-machines' #> -Function Remove-nbIpAddress { +Function Remove-nbRegion { Param ( - # ID of the IpAddress to delete + # ID of the Region to delete + [Parameter()] + [Int] + $Id + ) + try { + Remove-nbObject -Resource 'dcim/regions' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } +} + +<# +.SYNOPSIS + Deletes a ConsoleServerPortTemplate in Netbox +.DESCRIPTION + Deletes a netbox ConsoleServerPortTemplate by ID or via the pipeline. +.EXAMPLE + # Remove the ConsoleServerPortTemplate by id + Remove-nbConsoleServerPortTemplate -id 1 +.EXAMPLE + #Remove ConsoleServerPortTemplate returned from a get-nbConsoleServerPortTemplate + Get-NbConsoleServerPortTemplate -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbConsoleServerPortTemplate -Resource 'virtualization/virtual-machines' +#> +Function Remove-nbConsoleServerPortTemplate { + Param ( + # ID of the ConsoleServerPortTemplate to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'ipam/ip-addresses' -id $id + try { + Remove-nbObject -Resource 'dcim/console-server-port-templates' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# @@ -161,214 +212,254 @@ Function Remove-nbAggregate { [Int] $Id ) - Remove-nbObject -Resource 'ipam/aggregates' -id $id + try { + Remove-nbObject -Resource 'ipam/aggregates' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a PowerPortTemplate in Netbox + Deletes a ClusterType in Netbox .DESCRIPTION - Deletes a netbox PowerPortTemplate by ID or via the pipeline. + Deletes a netbox ClusterType by ID or via the pipeline. .EXAMPLE - # Remove the PowerPortTemplate by id - Remove-nbPowerPortTemplate -id 1 + # Remove the ClusterType by id + Remove-nbClusterType -id 1 .EXAMPLE - #Remove PowerPortTemplate returned from a get-nbPowerPortTemplate - Get-NbPowerPortTemplate -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbPowerPortTemplate -Resource 'virtualization/virtual-machines' + #Remove ClusterType returned from a get-nbClusterType + Get-NbClusterType -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbClusterType -Resource 'virtualization/virtual-machines' #> -Function Remove-nbPowerPortTemplate { +Function Remove-nbClusterType { Param ( - # ID of the PowerPortTemplate to delete + # ID of the ClusterType to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'dcim/power-port-templates' -id $id + try { + Remove-nbObject -Resource 'virtualization/cluster-types' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a ImageAttachment in Netbox + Deletes a Vlan in Netbox .DESCRIPTION - Deletes a netbox ImageAttachment by ID or via the pipeline. + Deletes a netbox Vlan by ID or via the pipeline. .EXAMPLE - # Remove the ImageAttachment by id - Remove-nbImageAttachment -id 1 + # Remove the Vlan by id + Remove-nbVlan -id 1 .EXAMPLE - #Remove ImageAttachment returned from a get-nbImageAttachment - Get-NbImageAttachment -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbImageAttachment -Resource 'virtualization/virtual-machines' + #Remove Vlan returned from a get-nbVlan + Get-NbVlan -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbVlan -Resource 'virtualization/virtual-machines' #> -Function Remove-nbImageAttachment { +Function Remove-nbVlan { Param ( - # ID of the ImageAttachment to delete + # ID of the Vlan to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'extras/image-attachments' -id $id + try { + Remove-nbObject -Resource 'ipam/vlans' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a ConsoleServerPort in Netbox + Deletes a Provider in Netbox .DESCRIPTION - Deletes a netbox ConsoleServerPort by ID or via the pipeline. + Deletes a netbox Provider by ID or via the pipeline. .EXAMPLE - # Remove the ConsoleServerPort by id - Remove-nbConsoleServerPort -id 1 + # Remove the Provider by id + Remove-nbProvider -id 1 .EXAMPLE - #Remove ConsoleServerPort returned from a get-nbConsoleServerPort - Get-NbConsoleServerPort -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbConsoleServerPort -Resource 'virtualization/virtual-machines' + #Remove Provider returned from a get-nbProvider + Get-NbProvider -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbProvider -Resource 'virtualization/virtual-machines' #> -Function Remove-nbConsoleServerPort { +Function Remove-nbProvider { Param ( - # ID of the ConsoleServerPort to delete + # ID of the Provider to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'dcim/console-server-ports' -id $id + try { + Remove-nbObject -Resource 'circuits/providers' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a InventoryItem in Netbox + Deletes a PowerConnection in Netbox .DESCRIPTION - Deletes a netbox InventoryItem by ID or via the pipeline. + Deletes a netbox PowerConnection by ID or via the pipeline. .EXAMPLE - # Remove the InventoryItem by id - Remove-nbInventoryItem -id 1 + # Remove the PowerConnection by id + Remove-nbPowerConnection -id 1 .EXAMPLE - #Remove InventoryItem returned from a get-nbInventoryItem - Get-NbInventoryItem -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbInventoryItem -Resource 'virtualization/virtual-machines' + #Remove PowerConnection returned from a get-nbPowerConnection + Get-NbPowerConnection -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbPowerConnection -Resource 'virtualization/virtual-machines' #> -Function Remove-nbInventoryItem { +Function Remove-nbPowerConnection { Param ( - # ID of the InventoryItem to delete + # ID of the PowerConnection to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'dcim/inventory-items' -id $id + try { + Remove-nbObject -Resource 'dcim/power-connections' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a Service in Netbox + Deletes a ConsolePort in Netbox .DESCRIPTION - Deletes a netbox Service by ID or via the pipeline. + Deletes a netbox ConsolePort by ID or via the pipeline. .EXAMPLE - # Remove the Service by id - Remove-nbService -id 1 + # Remove the ConsolePort by id + Remove-nbConsolePort -id 1 .EXAMPLE - #Remove Service returned from a get-nbService - Get-NbService -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbService -Resource 'virtualization/virtual-machines' + #Remove ConsolePort returned from a get-nbConsolePort + Get-NbConsolePort -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbConsolePort -Resource 'virtualization/virtual-machines' #> -Function Remove-nbService { +Function Remove-nbConsolePort { Param ( - # ID of the Service to delete + # ID of the ConsolePort to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'ipam/services' -id $id + try { + Remove-nbObject -Resource 'dcim/console-ports' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a ConsoleServerPortTemplate in Netbox + Deletes a VMInterface in Netbox .DESCRIPTION - Deletes a netbox ConsoleServerPortTemplate by ID or via the pipeline. + Deletes a netbox VMInterface by ID or via the pipeline. .EXAMPLE - # Remove the ConsoleServerPortTemplate by id - Remove-nbConsoleServerPortTemplate -id 1 + # Remove the VMInterface by id + Remove-nbVMInterface -id 1 .EXAMPLE - #Remove ConsoleServerPortTemplate returned from a get-nbConsoleServerPortTemplate - Get-NbConsoleServerPortTemplate -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbConsoleServerPortTemplate -Resource 'virtualization/virtual-machines' + #Remove VMInterface returned from a get-nbVMInterface + Get-NbVMInterface -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbVMInterface -Resource 'virtualization/virtual-machines' #> -Function Remove-nbConsoleServerPortTemplate { +Function Remove-nbVMInterface { Param ( - # ID of the ConsoleServerPortTemplate to delete + # ID of the VMInterface to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'dcim/console-server-port-templates' -id $id + try { + Remove-nbObject -Resource 'virtualization/interfaces' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a VirtualMachine in Netbox + Deletes a Platform in Netbox .DESCRIPTION - Deletes a netbox VirtualMachine by ID or via the pipeline. + Deletes a netbox Platform by ID or via the pipeline. .EXAMPLE - # Remove the VirtualMachine by id - Remove-nbVirtualMachine -id 1 + # Remove the Platform by id + Remove-nbPlatform -id 1 .EXAMPLE - #Remove VirtualMachine returned from a get-nbVirtualMachine - Get-NbVirtualMachine -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbVirtualMachine -Resource 'virtualization/virtual-machines' + #Remove Platform returned from a get-nbPlatform + Get-NbPlatform -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbPlatform -Resource 'virtualization/virtual-machines' #> -Function Remove-nbVirtualMachine { +Function Remove-nbPlatform { Param ( - # ID of the VirtualMachine to delete + # ID of the Platform to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'virtualization/virtual-machines' -id $id + try { + Remove-nbObject -Resource 'dcim/platforms' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a Rir in Netbox + Deletes a Circuit in Netbox .DESCRIPTION - Deletes a netbox Rir by ID or via the pipeline. + Deletes a netbox Circuit by ID or via the pipeline. .EXAMPLE - # Remove the Rir by id - Remove-nbRir -id 1 + # Remove the Circuit by id + Remove-nbCircuit -id 1 .EXAMPLE - #Remove Rir returned from a get-nbRir - Get-NbRir -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbRir -Resource 'virtualization/virtual-machines' + #Remove Circuit returned from a get-nbCircuit + Get-NbCircuit -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbCircuit -Resource 'virtualization/virtual-machines' #> -Function Remove-nbRir { +Function Remove-nbCircuit { Param ( - # ID of the Rir to delete + # ID of the Circuit to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'ipam/rirs' -id $id + try { + Remove-nbObject -Resource 'circuits/circuits' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a Report in Netbox + Deletes a RackReservation in Netbox .DESCRIPTION - Deletes a netbox Report by ID or via the pipeline. + Deletes a netbox RackReservation by ID or via the pipeline. .EXAMPLE - # Remove the Report by id - Remove-nbReport -id 1 + # Remove the RackReservation by id + Remove-nbRackReservation -id 1 .EXAMPLE - #Remove Report returned from a get-nbReport - Get-NbReport -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbReport -Resource 'virtualization/virtual-machines' + #Remove RackReservation returned from a get-nbRackReservation + Get-NbRackReservation -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbRackReservation -Resource 'virtualization/virtual-machines' #> -Function Remove-nbReport { +Function Remove-nbRackReservation { Param ( - # ID of the Report to delete + # ID of the RackReservation to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'extras/reports' -id $id + try { + Remove-nbObject -Resource 'dcim/rack-reservations' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# @@ -391,398 +482,470 @@ Function Remove-nbTenantGroup { [Int] $Id ) - Remove-nbObject -Resource 'tenancy/tenant-groups' -id $id + try { + Remove-nbObject -Resource 'tenancy/tenant-groups' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a TopologyMap in Netbox + Deletes a Devicebay in Netbox .DESCRIPTION - Deletes a netbox TopologyMap by ID or via the pipeline. + Deletes a netbox Devicebay by ID or via the pipeline. .EXAMPLE - # Remove the TopologyMap by id - Remove-nbTopologyMap -id 1 + # Remove the Devicebay by id + Remove-nbDevicebay -id 1 .EXAMPLE - #Remove TopologyMap returned from a get-nbTopologyMap - Get-NbTopologyMap -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbTopologyMap -Resource 'virtualization/virtual-machines' + #Remove Devicebay returned from a get-nbDevicebay + Get-NbDevicebay -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbDevicebay -Resource 'virtualization/virtual-machines' #> -Function Remove-nbTopologyMap { +Function Remove-nbDevicebay { Param ( - # ID of the TopologyMap to delete + # ID of the Devicebay to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'extras/topology-maps' -id $id + try { + Remove-nbObject -Resource 'dcim/device-bays' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a RackGroup in Netbox + Deletes a Rir in Netbox .DESCRIPTION - Deletes a netbox RackGroup by ID or via the pipeline. + Deletes a netbox Rir by ID or via the pipeline. .EXAMPLE - # Remove the RackGroup by id - Remove-nbRackGroup -id 1 + # Remove the Rir by id + Remove-nbRir -id 1 .EXAMPLE - #Remove RackGroup returned from a get-nbRackGroup - Get-NbRackGroup -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbRackGroup -Resource 'virtualization/virtual-machines' + #Remove Rir returned from a get-nbRir + Get-NbRir -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbRir -Resource 'virtualization/virtual-machines' #> -Function Remove-nbRackGroup { +Function Remove-nbRir { Param ( - # ID of the RackGroup to delete + # ID of the Rir to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'dcim/rack-groups' -id $id + try { + Remove-nbObject -Resource 'ipam/rirs' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a Provider in Netbox + Deletes a DevicebayTemplate in Netbox .DESCRIPTION - Deletes a netbox Provider by ID or via the pipeline. + Deletes a netbox DevicebayTemplate by ID or via the pipeline. .EXAMPLE - # Remove the Provider by id - Remove-nbProvider -id 1 + # Remove the DevicebayTemplate by id + Remove-nbDevicebayTemplate -id 1 .EXAMPLE - #Remove Provider returned from a get-nbProvider - Get-NbProvider -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbProvider -Resource 'virtualization/virtual-machines' + #Remove DevicebayTemplate returned from a get-nbDevicebayTemplate + Get-NbDevicebayTemplate -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbDevicebayTemplate -Resource 'virtualization/virtual-machines' #> -Function Remove-nbProvider { +Function Remove-nbDevicebayTemplate { Param ( - # ID of the Provider to delete + # ID of the DevicebayTemplate to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'circuits/providers' -id $id + try { + Remove-nbObject -Resource 'dcim/device-bay-templates' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a RackReservation in Netbox + Deletes a Graph in Netbox .DESCRIPTION - Deletes a netbox RackReservation by ID or via the pipeline. + Deletes a netbox Graph by ID or via the pipeline. .EXAMPLE - # Remove the RackReservation by id - Remove-nbRackReservation -id 1 + # Remove the Graph by id + Remove-nbGraph -id 1 .EXAMPLE - #Remove RackReservation returned from a get-nbRackReservation - Get-NbRackReservation -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbRackReservation -Resource 'virtualization/virtual-machines' + #Remove Graph returned from a get-nbGraph + Get-NbGraph -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbGraph -Resource 'virtualization/virtual-machines' #> -Function Remove-nbRackReservation { +Function Remove-nbGraph { Param ( - # ID of the RackReservation to delete + # ID of the Graph to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'dcim/rack-reservations' -id $id + try { + Remove-nbObject -Resource 'extras/graphs' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a PowerOutletTemplate in Netbox + Deletes a Interface in Netbox .DESCRIPTION - Deletes a netbox PowerOutletTemplate by ID or via the pipeline. + Deletes a netbox Interface by ID or via the pipeline. .EXAMPLE - # Remove the PowerOutletTemplate by id - Remove-nbPowerOutletTemplate -id 1 + # Remove the Interface by id + Remove-nbInterface -id 1 .EXAMPLE - #Remove PowerOutletTemplate returned from a get-nbPowerOutletTemplate - Get-NbPowerOutletTemplate -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbPowerOutletTemplate -Resource 'virtualization/virtual-machines' + #Remove Interface returned from a get-nbInterface + Get-NbInterface -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbInterface -Resource 'virtualization/virtual-machines' #> -Function Remove-nbPowerOutletTemplate { +Function Remove-nbInterface { Param ( - # ID of the PowerOutletTemplate to delete + # ID of the Interface to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'dcim/power-outlet-templates' -id $id + try { + Remove-nbObject -Resource 'dcim/interfaces' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a PowerOutlet in Netbox + Deletes a InterfaceConnection in Netbox .DESCRIPTION - Deletes a netbox PowerOutlet by ID or via the pipeline. + Deletes a netbox InterfaceConnection by ID or via the pipeline. .EXAMPLE - # Remove the PowerOutlet by id - Remove-nbPowerOutlet -id 1 + # Remove the InterfaceConnection by id + Remove-nbInterfaceConnection -id 1 .EXAMPLE - #Remove PowerOutlet returned from a get-nbPowerOutlet - Get-NbPowerOutlet -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbPowerOutlet -Resource 'virtualization/virtual-machines' + #Remove InterfaceConnection returned from a get-nbInterfaceConnection + Get-NbInterfaceConnection -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbInterfaceConnection -Resource 'virtualization/virtual-machines' #> -Function Remove-nbPowerOutlet { +Function Remove-nbInterfaceConnection { Param ( - # ID of the PowerOutlet to delete + # ID of the InterfaceConnection to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'dcim/power-outlets' -id $id + try { + Remove-nbObject -Resource 'dcim/interface-connections' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a Circuit in Netbox + Deletes a Role in Netbox .DESCRIPTION - Deletes a netbox Circuit by ID or via the pipeline. + Deletes a netbox Role by ID or via the pipeline. .EXAMPLE - # Remove the Circuit by id - Remove-nbCircuit -id 1 + # Remove the Role by id + Remove-nbRole -id 1 .EXAMPLE - #Remove Circuit returned from a get-nbCircuit - Get-NbCircuit -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbCircuit -Resource 'virtualization/virtual-machines' + #Remove Role returned from a get-nbRole + Get-NbRole -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbRole -Resource 'virtualization/virtual-machines' #> -Function Remove-nbCircuit { +Function Remove-nbRole { Param ( - # ID of the Circuit to delete + # ID of the Role to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'circuits/circuits' -id $id + try { + Remove-nbObject -Resource 'ipam/roles' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a Graph in Netbox + Deletes a ImageAttachment in Netbox .DESCRIPTION - Deletes a netbox Graph by ID or via the pipeline. + Deletes a netbox ImageAttachment by ID or via the pipeline. .EXAMPLE - # Remove the Graph by id - Remove-nbGraph -id 1 + # Remove the ImageAttachment by id + Remove-nbImageAttachment -id 1 .EXAMPLE - #Remove Graph returned from a get-nbGraph - Get-NbGraph -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbGraph -Resource 'virtualization/virtual-machines' + #Remove ImageAttachment returned from a get-nbImageAttachment + Get-NbImageAttachment -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbImageAttachment -Resource 'virtualization/virtual-machines' #> -Function Remove-nbGraph { +Function Remove-nbImageAttachment { Param ( - # ID of the Graph to delete + # ID of the ImageAttachment to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'extras/graphs' -id $id + try { + Remove-nbObject -Resource 'extras/image-attachments' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a Device in Netbox + Deletes a Rack in Netbox .DESCRIPTION - Deletes a netbox Device by ID or via the pipeline. + Deletes a netbox Rack by ID or via the pipeline. .EXAMPLE - # Remove the Device by id - Remove-nbDevice -id 1 + # Remove the Rack by id + Remove-nbRack -id 1 .EXAMPLE - #Remove Device returned from a get-nbDevice - Get-NbDevice -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbDevice -Resource 'virtualization/virtual-machines' + #Remove Rack returned from a get-nbRack + Get-NbRack -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbRack -Resource 'virtualization/virtual-machines' #> -Function Remove-nbDevice { +Function Remove-nbRack { Param ( - # ID of the Device to delete + # ID of the Rack to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'dcim/devices' -id $id + try { + Remove-nbObject -Resource 'dcim/racks' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a VirtualChassis in Netbox + Deletes a ConsolePortTemplate in Netbox .DESCRIPTION - Deletes a netbox VirtualChassis by ID or via the pipeline. + Deletes a netbox ConsolePortTemplate by ID or via the pipeline. .EXAMPLE - # Remove the VirtualChassis by id - Remove-nbVirtualChassis -id 1 + # Remove the ConsolePortTemplate by id + Remove-nbConsolePortTemplate -id 1 .EXAMPLE - #Remove VirtualChassis returned from a get-nbVirtualChassis - Get-NbVirtualChassis -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbVirtualChassis -Resource 'virtualization/virtual-machines' + #Remove ConsolePortTemplate returned from a get-nbConsolePortTemplate + Get-NbConsolePortTemplate -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbConsolePortTemplate -Resource 'virtualization/virtual-machines' #> -Function Remove-nbVirtualChassis { +Function Remove-nbConsolePortTemplate { Param ( - # ID of the VirtualChassis to delete + # ID of the ConsolePortTemplate to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'dcim/virtual-chassis' -id $id + try { + Remove-nbObject -Resource 'dcim/console-port-templates' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a DevicebayTemplate in Netbox + Deletes a InterfaceTemplate in Netbox .DESCRIPTION - Deletes a netbox DevicebayTemplate by ID or via the pipeline. + Deletes a netbox InterfaceTemplate by ID or via the pipeline. .EXAMPLE - # Remove the DevicebayTemplate by id - Remove-nbDevicebayTemplate -id 1 + # Remove the InterfaceTemplate by id + Remove-nbInterfaceTemplate -id 1 .EXAMPLE - #Remove DevicebayTemplate returned from a get-nbDevicebayTemplate - Get-NbDevicebayTemplate -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbDevicebayTemplate -Resource 'virtualization/virtual-machines' + #Remove InterfaceTemplate returned from a get-nbInterfaceTemplate + Get-NbInterfaceTemplate -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbInterfaceTemplate -Resource 'virtualization/virtual-machines' #> -Function Remove-nbDevicebayTemplate { +Function Remove-nbInterfaceTemplate { Param ( - # ID of the DevicebayTemplate to delete + # ID of the InterfaceTemplate to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'dcim/device-bay-templates' -id $id + try { + Remove-nbObject -Resource 'dcim/interface-templates' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a ConsoleConnection in Netbox + Deletes a ExportTemplate in Netbox .DESCRIPTION - Deletes a netbox ConsoleConnection by ID or via the pipeline. + Deletes a netbox ExportTemplate by ID or via the pipeline. .EXAMPLE - # Remove the ConsoleConnection by id - Remove-nbConsoleConnection -id 1 + # Remove the ExportTemplate by id + Remove-nbExportTemplate -id 1 .EXAMPLE - #Remove ConsoleConnection returned from a get-nbConsoleConnection - Get-NbConsoleConnection -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbConsoleConnection -Resource 'virtualization/virtual-machines' + #Remove ExportTemplate returned from a get-nbExportTemplate + Get-NbExportTemplate -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbExportTemplate -Resource 'virtualization/virtual-machines' #> -Function Remove-nbConsoleConnection { +Function Remove-nbExportTemplate { Param ( - # ID of the ConsoleConnection to delete + # ID of the ExportTemplate to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'dcim/console-connections' -id $id + try { + Remove-nbObject -Resource 'extras/export-templates' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a RackRole in Netbox + Deletes a Cluster in Netbox .DESCRIPTION - Deletes a netbox RackRole by ID or via the pipeline. + Deletes a netbox Cluster by ID or via the pipeline. .EXAMPLE - # Remove the RackRole by id - Remove-nbRackRole -id 1 + # Remove the Cluster by id + Remove-nbCluster -id 1 .EXAMPLE - #Remove RackRole returned from a get-nbRackRole - Get-NbRackRole -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbRackRole -Resource 'virtualization/virtual-machines' + #Remove Cluster returned from a get-nbCluster + Get-NbCluster -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbCluster -Resource 'virtualization/virtual-machines' #> -Function Remove-nbRackRole { +Function Remove-nbCluster { Param ( - # ID of the RackRole to delete + # ID of the Cluster to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'dcim/rack-roles' -id $id + try { + Remove-nbObject -Resource 'virtualization/clusters' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a Platform in Netbox + Deletes a Service in Netbox .DESCRIPTION - Deletes a netbox Platform by ID or via the pipeline. + Deletes a netbox Service by ID or via the pipeline. .EXAMPLE - # Remove the Platform by id - Remove-nbPlatform -id 1 + # Remove the Service by id + Remove-nbService -id 1 .EXAMPLE - #Remove Platform returned from a get-nbPlatform - Get-NbPlatform -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbPlatform -Resource 'virtualization/virtual-machines' + #Remove Service returned from a get-nbService + Get-NbService -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbService -Resource 'virtualization/virtual-machines' #> -Function Remove-nbPlatform { +Function Remove-nbService { Param ( - # ID of the Platform to delete + # ID of the Service to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'dcim/platforms' -id $id + try { + Remove-nbObject -Resource 'ipam/services' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a Vlan in Netbox + Deletes a RackRole in Netbox .DESCRIPTION - Deletes a netbox Vlan by ID or via the pipeline. + Deletes a netbox RackRole by ID or via the pipeline. .EXAMPLE - # Remove the Vlan by id - Remove-nbVlan -id 1 + # Remove the RackRole by id + Remove-nbRackRole -id 1 .EXAMPLE - #Remove Vlan returned from a get-nbVlan - Get-NbVlan -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbVlan -Resource 'virtualization/virtual-machines' + #Remove RackRole returned from a get-nbRackRole + Get-NbRackRole -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbRackRole -Resource 'virtualization/virtual-machines' #> -Function Remove-nbVlan { +Function Remove-nbRackRole { Param ( - # ID of the Vlan to delete + # ID of the RackRole to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'ipam/vlans' -id $id + try { + Remove-nbObject -Resource 'dcim/rack-roles' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a RecentActivity in Netbox + Deletes a CircuitType in Netbox .DESCRIPTION - Deletes a netbox RecentActivity by ID or via the pipeline. + Deletes a netbox CircuitType by ID or via the pipeline. .EXAMPLE - # Remove the RecentActivity by id - Remove-nbRecentActivity -id 1 + # Remove the CircuitType by id + Remove-nbCircuitType -id 1 .EXAMPLE - #Remove RecentActivity returned from a get-nbRecentActivity - Get-NbRecentActivity -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbRecentActivity -Resource 'virtualization/virtual-machines' + #Remove CircuitType returned from a get-nbCircuitType + Get-NbCircuitType -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbCircuitType -Resource 'virtualization/virtual-machines' #> -Function Remove-nbRecentActivity { +Function Remove-nbCircuitType { Param ( - # ID of the RecentActivity to delete + # ID of the CircuitType to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'extras/recent-activity' -id $id + try { + Remove-nbObject -Resource 'circuits/circuit-types' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a Region in Netbox + Deletes a Report in Netbox .DESCRIPTION - Deletes a netbox Region by ID or via the pipeline. + Deletes a netbox Report by ID or via the pipeline. .EXAMPLE - # Remove the Region by id - Remove-nbRegion -id 1 + # Remove the Report by id + Remove-nbReport -id 1 .EXAMPLE - #Remove Region returned from a get-nbRegion - Get-NbRegion -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbRegion -Resource 'virtualization/virtual-machines' + #Remove Report returned from a get-nbReport + Get-NbReport -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbReport -Resource 'virtualization/virtual-machines' #> -Function Remove-nbRegion { +Function Remove-nbReport { Param ( - # ID of the Region to delete + # ID of the Report to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'dcim/regions' -id $id + try { + Remove-nbObject -Resource 'extras/reports' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# @@ -805,466 +968,523 @@ Function Remove-nbManufacturer { [Int] $Id ) - Remove-nbObject -Resource 'dcim/manufacturers' -id $id -} - -<# -.SYNOPSIS - Deletes a VlanGroup in Netbox -.DESCRIPTION - Deletes a netbox VlanGroup by ID or via the pipeline. -.EXAMPLE - # Remove the VlanGroup by id - Remove-nbVlanGroup -id 1 -.EXAMPLE - #Remove VlanGroup returned from a get-nbVlanGroup - Get-NbVlanGroup -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbVlanGroup -Resource 'virtualization/virtual-machines' -#> -Function Remove-nbVlanGroup { - Param ( - # ID of the VlanGroup to delete - [Parameter()] - [Int] - $Id - ) - Remove-nbObject -Resource 'ipam/vlan-groups' -id $id + try { + Remove-nbObject -Resource 'dcim/manufacturers' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a Tenant in Netbox + Deletes a RackGroup in Netbox .DESCRIPTION - Deletes a netbox Tenant by ID or via the pipeline. + Deletes a netbox RackGroup by ID or via the pipeline. .EXAMPLE - # Remove the Tenant by id - Remove-nbTenant -id 1 + # Remove the RackGroup by id + Remove-nbRackGroup -id 1 .EXAMPLE - #Remove Tenant returned from a get-nbTenant - Get-NbTenant -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbTenant -Resource 'virtualization/virtual-machines' + #Remove RackGroup returned from a get-nbRackGroup + Get-NbRackGroup -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbRackGroup -Resource 'virtualization/virtual-machines' #> -Function Remove-nbTenant { +Function Remove-nbRackGroup { Param ( - # ID of the Tenant to delete + # ID of the RackGroup to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'tenancy/tenants' -id $id + try { + Remove-nbObject -Resource 'dcim/rack-groups' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a DeviceType in Netbox + Deletes a IpAddress in Netbox .DESCRIPTION - Deletes a netbox DeviceType by ID or via the pipeline. + Deletes a netbox IpAddress by ID or via the pipeline. .EXAMPLE - # Remove the DeviceType by id - Remove-nbDeviceType -id 1 + # Remove the IpAddress by id + Remove-nbIpAddress -id 1 .EXAMPLE - #Remove DeviceType returned from a get-nbDeviceType - Get-NbDeviceType -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbDeviceType -Resource 'virtualization/virtual-machines' + #Remove IpAddress returned from a get-nbIpAddress + Get-NbIpAddress -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbIpAddress -Resource 'virtualization/virtual-machines' #> -Function Remove-nbDeviceType { +Function Remove-nbIpAddress { Param ( - # ID of the DeviceType to delete + # ID of the IpAddress to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'dcim/device-types' -id $id + try { + Remove-nbObject -Resource 'ipam/ip-addresses' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a CircuitTermination in Netbox + Deletes a Vrf in Netbox .DESCRIPTION - Deletes a netbox CircuitTermination by ID or via the pipeline. + Deletes a netbox Vrf by ID or via the pipeline. .EXAMPLE - # Remove the CircuitTermination by id - Remove-nbCircuitTermination -id 1 + # Remove the Vrf by id + Remove-nbVrf -id 1 .EXAMPLE - #Remove CircuitTermination returned from a get-nbCircuitTermination - Get-NbCircuitTermination -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbCircuitTermination -Resource 'virtualization/virtual-machines' + #Remove Vrf returned from a get-nbVrf + Get-NbVrf -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbVrf -Resource 'virtualization/virtual-machines' #> -Function Remove-nbCircuitTermination { +Function Remove-nbVrf { Param ( - # ID of the CircuitTermination to delete + # ID of the Vrf to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'circuits/circuit-terminations' -id $id + try { + Remove-nbObject -Resource 'ipam/vrfs' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a ClusterType in Netbox + Deletes a Device in Netbox .DESCRIPTION - Deletes a netbox ClusterType by ID or via the pipeline. + Deletes a netbox Device by ID or via the pipeline. .EXAMPLE - # Remove the ClusterType by id - Remove-nbClusterType -id 1 + # Remove the Device by id + Remove-nbDevice -id 1 .EXAMPLE - #Remove ClusterType returned from a get-nbClusterType - Get-NbClusterType -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbClusterType -Resource 'virtualization/virtual-machines' + #Remove Device returned from a get-nbDevice + Get-NbDevice -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbDevice -Resource 'virtualization/virtual-machines' #> -Function Remove-nbClusterType { +Function Remove-nbDevice { Param ( - # ID of the ClusterType to delete + # ID of the Device to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'virtualization/cluster-types' -id $id + try { + Remove-nbObject -Resource 'dcim/devices' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a PowerPort in Netbox + Deletes a Tenant in Netbox .DESCRIPTION - Deletes a netbox PowerPort by ID or via the pipeline. + Deletes a netbox Tenant by ID or via the pipeline. .EXAMPLE - # Remove the PowerPort by id - Remove-nbPowerPort -id 1 + # Remove the Tenant by id + Remove-nbTenant -id 1 .EXAMPLE - #Remove PowerPort returned from a get-nbPowerPort - Get-NbPowerPort -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbPowerPort -Resource 'virtualization/virtual-machines' + #Remove Tenant returned from a get-nbTenant + Get-NbTenant -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbTenant -Resource 'virtualization/virtual-machines' #> -Function Remove-nbPowerPort { +Function Remove-nbTenant { Param ( - # ID of the PowerPort to delete + # ID of the Tenant to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'dcim/power-ports' -id $id + try { + Remove-nbObject -Resource 'tenancy/tenants' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a Role in Netbox + Deletes a PowerOutletTemplate in Netbox .DESCRIPTION - Deletes a netbox Role by ID or via the pipeline. + Deletes a netbox PowerOutletTemplate by ID or via the pipeline. .EXAMPLE - # Remove the Role by id - Remove-nbRole -id 1 + # Remove the PowerOutletTemplate by id + Remove-nbPowerOutletTemplate -id 1 .EXAMPLE - #Remove Role returned from a get-nbRole - Get-NbRole -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbRole -Resource 'virtualization/virtual-machines' + #Remove PowerOutletTemplate returned from a get-nbPowerOutletTemplate + Get-NbPowerOutletTemplate -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbPowerOutletTemplate -Resource 'virtualization/virtual-machines' #> -Function Remove-nbRole { +Function Remove-nbPowerOutletTemplate { Param ( - # ID of the Role to delete + # ID of the PowerOutletTemplate to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'ipam/roles' -id $id + try { + Remove-nbObject -Resource 'dcim/power-outlet-templates' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a Vrf in Netbox + Deletes a InventoryItem in Netbox .DESCRIPTION - Deletes a netbox Vrf by ID or via the pipeline. + Deletes a netbox InventoryItem by ID or via the pipeline. .EXAMPLE - # Remove the Vrf by id - Remove-nbVrf -id 1 + # Remove the InventoryItem by id + Remove-nbInventoryItem -id 1 .EXAMPLE - #Remove Vrf returned from a get-nbVrf - Get-NbVrf -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbVrf -Resource 'virtualization/virtual-machines' + #Remove InventoryItem returned from a get-nbInventoryItem + Get-NbInventoryItem -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbInventoryItem -Resource 'virtualization/virtual-machines' #> -Function Remove-nbVrf { +Function Remove-nbInventoryItem { Param ( - # ID of the Vrf to delete + # ID of the InventoryItem to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'ipam/vrfs' -id $id + try { + Remove-nbObject -Resource 'dcim/inventory-items' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a Rack in Netbox + Deletes a ConsoleServerPort in Netbox .DESCRIPTION - Deletes a netbox Rack by ID or via the pipeline. + Deletes a netbox ConsoleServerPort by ID or via the pipeline. .EXAMPLE - # Remove the Rack by id - Remove-nbRack -id 1 + # Remove the ConsoleServerPort by id + Remove-nbConsoleServerPort -id 1 .EXAMPLE - #Remove Rack returned from a get-nbRack - Get-NbRack -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbRack -Resource 'virtualization/virtual-machines' + #Remove ConsoleServerPort returned from a get-nbConsoleServerPort + Get-NbConsoleServerPort -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbConsoleServerPort -Resource 'virtualization/virtual-machines' #> -Function Remove-nbRack { +Function Remove-nbConsoleServerPort { Param ( - # ID of the Rack to delete + # ID of the ConsoleServerPort to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'dcim/racks' -id $id + try { + Remove-nbObject -Resource 'dcim/console-server-ports' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a Cluster in Netbox + Deletes a VirtualChassis in Netbox .DESCRIPTION - Deletes a netbox Cluster by ID or via the pipeline. + Deletes a netbox VirtualChassis by ID or via the pipeline. .EXAMPLE - # Remove the Cluster by id - Remove-nbCluster -id 1 + # Remove the VirtualChassis by id + Remove-nbVirtualChassis -id 1 .EXAMPLE - #Remove Cluster returned from a get-nbCluster - Get-NbCluster -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbCluster -Resource 'virtualization/virtual-machines' + #Remove VirtualChassis returned from a get-nbVirtualChassis + Get-NbVirtualChassis -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbVirtualChassis -Resource 'virtualization/virtual-machines' #> -Function Remove-nbCluster { +Function Remove-nbVirtualChassis { Param ( - # ID of the Cluster to delete + # ID of the VirtualChassis to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'virtualization/clusters' -id $id + try { + Remove-nbObject -Resource 'dcim/virtual-chassis' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a Site in Netbox + Deletes a VirtualMachine in Netbox .DESCRIPTION - Deletes a netbox Site by ID or via the pipeline. + Deletes a netbox VirtualMachine by ID or via the pipeline. .EXAMPLE - # Remove the Site by id - Remove-nbSite -id 1 + # Remove the VirtualMachine by id + Remove-nbVirtualMachine -id 1 .EXAMPLE - #Remove Site returned from a get-nbSite - Get-NbSite -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbSite -Resource 'virtualization/virtual-machines' + #Remove VirtualMachine returned from a get-nbVirtualMachine + Get-NbVirtualMachine -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbVirtualMachine -Resource 'virtualization/virtual-machines' #> -Function Remove-nbSite { +Function Remove-nbVirtualMachine { Param ( - # ID of the Site to delete + # ID of the VirtualMachine to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'dcim/sites' -id $id + try { + Remove-nbObject -Resource 'virtualization/virtual-machines' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a ClusterGroup in Netbox + Deletes a PowerPort in Netbox .DESCRIPTION - Deletes a netbox ClusterGroup by ID or via the pipeline. + Deletes a netbox PowerPort by ID or via the pipeline. .EXAMPLE - # Remove the ClusterGroup by id - Remove-nbClusterGroup -id 1 + # Remove the PowerPort by id + Remove-nbPowerPort -id 1 .EXAMPLE - #Remove ClusterGroup returned from a get-nbClusterGroup - Get-NbClusterGroup -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbClusterGroup -Resource 'virtualization/virtual-machines' + #Remove PowerPort returned from a get-nbPowerPort + Get-NbPowerPort -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbPowerPort -Resource 'virtualization/virtual-machines' #> -Function Remove-nbClusterGroup { +Function Remove-nbPowerPort { Param ( - # ID of the ClusterGroup to delete + # ID of the PowerPort to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'virtualization/cluster-groups' -id $id + try { + Remove-nbObject -Resource 'dcim/power-ports' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a InterfaceConnection in Netbox + Deletes a PowerPortTemplate in Netbox .DESCRIPTION - Deletes a netbox InterfaceConnection by ID or via the pipeline. + Deletes a netbox PowerPortTemplate by ID or via the pipeline. .EXAMPLE - # Remove the InterfaceConnection by id - Remove-nbInterfaceConnection -id 1 + # Remove the PowerPortTemplate by id + Remove-nbPowerPortTemplate -id 1 .EXAMPLE - #Remove InterfaceConnection returned from a get-nbInterfaceConnection - Get-NbInterfaceConnection -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbInterfaceConnection -Resource 'virtualization/virtual-machines' + #Remove PowerPortTemplate returned from a get-nbPowerPortTemplate + Get-NbPowerPortTemplate -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbPowerPortTemplate -Resource 'virtualization/virtual-machines' #> -Function Remove-nbInterfaceConnection { +Function Remove-nbPowerPortTemplate { Param ( - # ID of the InterfaceConnection to delete + # ID of the PowerPortTemplate to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'dcim/interface-connections' -id $id + try { + Remove-nbObject -Resource 'dcim/power-port-templates' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a CircuitType in Netbox + Deletes a ConsoleConnection in Netbox .DESCRIPTION - Deletes a netbox CircuitType by ID or via the pipeline. + Deletes a netbox ConsoleConnection by ID or via the pipeline. .EXAMPLE - # Remove the CircuitType by id - Remove-nbCircuitType -id 1 + # Remove the ConsoleConnection by id + Remove-nbConsoleConnection -id 1 .EXAMPLE - #Remove CircuitType returned from a get-nbCircuitType - Get-NbCircuitType -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbCircuitType -Resource 'virtualization/virtual-machines' + #Remove ConsoleConnection returned from a get-nbConsoleConnection + Get-NbConsoleConnection -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbConsoleConnection -Resource 'virtualization/virtual-machines' #> -Function Remove-nbCircuitType { +Function Remove-nbConsoleConnection { Param ( - # ID of the CircuitType to delete + # ID of the ConsoleConnection to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'circuits/circuit-types' -id $id + try { + Remove-nbObject -Resource 'dcim/console-connections' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a DeviceRole in Netbox + Deletes a TopologyMap in Netbox .DESCRIPTION - Deletes a netbox DeviceRole by ID or via the pipeline. + Deletes a netbox TopologyMap by ID or via the pipeline. .EXAMPLE - # Remove the DeviceRole by id - Remove-nbDeviceRole -id 1 + # Remove the TopologyMap by id + Remove-nbTopologyMap -id 1 .EXAMPLE - #Remove DeviceRole returned from a get-nbDeviceRole - Get-NbDeviceRole -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbDeviceRole -Resource 'virtualization/virtual-machines' + #Remove TopologyMap returned from a get-nbTopologyMap + Get-NbTopologyMap -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbTopologyMap -Resource 'virtualization/virtual-machines' #> -Function Remove-nbDeviceRole { +Function Remove-nbTopologyMap { Param ( - # ID of the DeviceRole to delete + # ID of the TopologyMap to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'dcim/device-roles' -id $id + try { + Remove-nbObject -Resource 'extras/topology-maps' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a VMInterface in Netbox + Deletes a CircuitTermination in Netbox .DESCRIPTION - Deletes a netbox VMInterface by ID or via the pipeline. + Deletes a netbox CircuitTermination by ID or via the pipeline. .EXAMPLE - # Remove the VMInterface by id - Remove-nbVMInterface -id 1 + # Remove the CircuitTermination by id + Remove-nbCircuitTermination -id 1 .EXAMPLE - #Remove VMInterface returned from a get-nbVMInterface - Get-NbVMInterface -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbVMInterface -Resource 'virtualization/virtual-machines' + #Remove CircuitTermination returned from a get-nbCircuitTermination + Get-NbCircuitTermination -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbCircuitTermination -Resource 'virtualization/virtual-machines' #> -Function Remove-nbVMInterface { +Function Remove-nbCircuitTermination { Param ( - # ID of the VMInterface to delete + # ID of the CircuitTermination to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'virtualization/interfaces' -id $id + try { + Remove-nbObject -Resource 'circuits/circuit-terminations' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a ConsolePort in Netbox + Deletes a RecentActivity in Netbox .DESCRIPTION - Deletes a netbox ConsolePort by ID or via the pipeline. + Deletes a netbox RecentActivity by ID or via the pipeline. .EXAMPLE - # Remove the ConsolePort by id - Remove-nbConsolePort -id 1 + # Remove the RecentActivity by id + Remove-nbRecentActivity -id 1 .EXAMPLE - #Remove ConsolePort returned from a get-nbConsolePort - Get-NbConsolePort -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbConsolePort -Resource 'virtualization/virtual-machines' + #Remove RecentActivity returned from a get-nbRecentActivity + Get-NbRecentActivity -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbRecentActivity -Resource 'virtualization/virtual-machines' #> -Function Remove-nbConsolePort { +Function Remove-nbRecentActivity { Param ( - # ID of the ConsolePort to delete + # ID of the RecentActivity to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'dcim/console-ports' -id $id + try { + Remove-nbObject -Resource 'extras/recent-activity' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a Devicebay in Netbox + Deletes a Prefix in Netbox .DESCRIPTION - Deletes a netbox Devicebay by ID or via the pipeline. + Deletes a netbox Prefix by ID or via the pipeline. .EXAMPLE - # Remove the Devicebay by id - Remove-nbDevicebay -id 1 + # Remove the Prefix by id + Remove-nbPrefix -id 1 .EXAMPLE - #Remove Devicebay returned from a get-nbDevicebay - Get-NbDevicebay -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbDevicebay -Resource 'virtualization/virtual-machines' + #Remove Prefix returned from a get-nbPrefix + Get-NbPrefix -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbPrefix -Resource 'virtualization/virtual-machines' #> -Function Remove-nbDevicebay { +Function Remove-nbPrefix { Param ( - # ID of the Devicebay to delete + # ID of the Prefix to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'dcim/device-bays' -id $id + try { + Remove-nbObject -Resource 'ipam/prefixes' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a InterfaceTemplate in Netbox + Deletes a DeviceRole in Netbox .DESCRIPTION - Deletes a netbox InterfaceTemplate by ID or via the pipeline. + Deletes a netbox DeviceRole by ID or via the pipeline. .EXAMPLE - # Remove the InterfaceTemplate by id - Remove-nbInterfaceTemplate -id 1 + # Remove the DeviceRole by id + Remove-nbDeviceRole -id 1 .EXAMPLE - #Remove InterfaceTemplate returned from a get-nbInterfaceTemplate - Get-NbInterfaceTemplate -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbInterfaceTemplate -Resource 'virtualization/virtual-machines' + #Remove DeviceRole returned from a get-nbDeviceRole + Get-NbDeviceRole -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbDeviceRole -Resource 'virtualization/virtual-machines' #> -Function Remove-nbInterfaceTemplate { +Function Remove-nbDeviceRole { Param ( - # ID of the InterfaceTemplate to delete + # ID of the DeviceRole to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'dcim/interface-templates' -id $id + try { + Remove-nbObject -Resource 'dcim/device-roles' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Deletes a ExportTemplate in Netbox + Deletes a Site in Netbox .DESCRIPTION - Deletes a netbox ExportTemplate by ID or via the pipeline. + Deletes a netbox Site by ID or via the pipeline. .EXAMPLE - # Remove the ExportTemplate by id - Remove-nbExportTemplate -id 1 + # Remove the Site by id + Remove-nbSite -id 1 .EXAMPLE - #Remove ExportTemplate returned from a get-nbExportTemplate - Get-NbExportTemplate -search mything.contoso.com -Resource 'virtualization/virtual-machines' | - Remove-nbExportTemplate -Resource 'virtualization/virtual-machines' + #Remove Site returned from a get-nbSite + Get-NbSite -search mything.contoso.com -Resource 'virtualization/virtual-machines' | + Remove-nbSite -Resource 'virtualization/virtual-machines' #> -Function Remove-nbExportTemplate { +Function Remove-nbSite { Param ( - # ID of the ExportTemplate to delete + # ID of the Site to delete [Parameter()] [Int] $Id ) - Remove-nbObject -Resource 'extras/export-templates' -id $id + try { + Remove-nbObject -Resource 'dcim/sites' -id $id + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } diff --git a/module/Public/Set-nbObject.ps1 b/module/Public/Set-nbObject.ps1 index 9994a33..06363e9 100644 --- a/module/Public/Set-nbObject.ps1 +++ b/module/Public/Set-nbObject.ps1 @@ -52,79 +52,91 @@ function Set-nbObject { $Patch, # The Object to set - [Parameter(Mandatory=$true)] + [Parameter(Mandatory = $true)] $Object ) - if (!$id) { - if (!($Object.id)) { - $errorRecord = New-Object System.Management.Automation.ErrorRecord( - (New-Object Exception "No ID specified to set. Maybe you wanted $($myinvocation.Line -replace 'Set-nb','New-nb')"), - 'No.ID', - [System.Management.Automation.ErrorCategory]::ObjectNotFound, - $Resource - ) - $PSCmdlet.ThrowTerminatingError($errorRecord) + try { + if (!$id) { + if (!($Object.id)) { + $errorRecord = New-Object System.Management.Automation.ErrorRecord( + (New-Object Exception "No ID specified to set. Maybe you wanted $($myinvocation.Line -replace 'Set-nb','New-nb')"), + 'No.ID', + [System.Management.Automation.ErrorCategory]::ObjectNotFound, + $Resource + ) + $PSCmdlet.ThrowTerminatingError($errorRecord) + } + $id = $object.id } - $id = $object.id - } - if ($Patch.IsPresent) { - $OldObject = Get-nbobject -Resource $Resource/$id #-UnFlatten - foreach ($property in $OldObject._lookup) { - if ($OldObject."_$Property:id") { - $OldObject."$property" = $OldObject."_$Property:id" - } else { - $Lookup += $property + if ($Patch.IsPresent) { + $OldObject = Get-nbobject -Resource $Resource/$id #-UnFlatten + foreach ($property in $OldObject._lookup) { + if ($OldObject."_$Property:id") { + $OldObject."$property" = $OldObject."_$Property:id" + } + else { + $Lookup += $property + } } + $OldObject = $OldObject | Select-Object -Property * -ExcludeProperty _* } - $OldObject = $OldObject | Select-Object -Property * -ExcludeProperty _* - } - #put ids that are still on the object back and maybe pull - if ($Object._lookup) { - foreach ($property in $Object._lookup) { - if ($Object."_$Property:id") { - $Object."$property" = $Object."_$Property:id" - } else { - $Lookup += $property + #put ids that are still on the object back and maybe pull + if ($Object._lookup) { + foreach ($property in $Object._lookup) { + if ($Object."_$Property:id") { + $Object."$property" = $Object."_$Property:id" + } + else { + $Lookup += $property + } } } - } - if ($Object._CustomProperties) { - $CustomProperties += $Object._CustomProperties - } - #Automatically rip out all of the _ properties returned by get-nbobject - $object = $Object | Select-Object -Property * -ExcludeProperty _* + if ($Object._CustomProperties) { + $CustomProperties += $Object._CustomProperties + } + #Automatically rip out all of the _ properties returned by get-nbobject + $object = $Object | Select-Object -Property * -ExcludeProperty _* - $mapObject = @{custom_fields = @{}} - :maploop foreach ($property in $object.psobject.properties) { - $Name = $Property.name -replace '-' -replace ':' - $value = $Property.value - if ($Patch.IsPresent) { - if( [string]::IsNullOrEmpty( $($OldObject."$name") ) -and [string]::IsNullOrEmpty($value) ) { - Write-Verbose "Bypassing property $name (values are empty)" - continue :maploop + $mapObject = @{custom_fields = @{} } + :maploop foreach ($property in $object.psobject.properties) { + $Name = $Property.name -replace '-' -replace ':' + $value = $Property.value + if ($Patch.IsPresent) { + if ( [string]::IsNullOrEmpty( $($OldObject."$name") ) -and [string]::IsNullOrEmpty($value) ) { + Write-Verbose "Bypassing property $name (values are empty)" + continue :maploop + } + If ( ($OldObject."$name" -eq $value) -and ( $object."$name" -isnot [System.Array]) ) { + Write-Verbose "Bypassing property $name (Values are similar and object isn't an array)" + continue :maploop + } + } + if ($name -in $lookup.keys) { + $value = ConvertTo-nbID -source $value -value $name } - If( ($OldObject."$name" -eq $value) -and ( $object."$name" -isnot [System.Array]) ) { - Write-Verbose "Bypassing property $name (Values are similar and object isn't an array)" - continue :maploop + if ($name -in $CustomProperties) { + $mapObject.custom_fields[$name] = $value + } + elseif ($name -eq 'custom_fields') { + $mapObject.custom_fields += $value + } + else { + Write-Verbose "Adding property $name" + $mapObject[$name] = $value } } - if ($name -in $lookup.keys) { - $value = ConvertTo-nbID -source $value -value $name + if ($mapObject.custom_fields.Keys.Count -eq 0) { + $mapObject.Remove("custom_fields") } - if ($name -in $CustomProperties) { - $mapObject.custom_fields[$name] = $value - } elseif ($name -eq 'custom_fields') { - $mapObject.custom_fields += $value - } else { - Write-Verbose "Adding property $name" - $mapObject[$name] = $value + $mapObject = New-Object -TypeName psobject -Property $mapObject + if ($Patch.IsPresent) { + #$notChanged = $mapObject | compare-object -ReferenceObject $OldObject -ExcludeDifferent -PassThru + #$mapObject = $mapObject | Select-Object -ExcludeProperty $notChanged + return Invoke-nbApi -Resource $Resource/$id -HttpVerb Patch -Body ($mapObject | ConvertTo-Json -Compress) } + return Invoke-nbApi -Resource $Resource/$id -HttpVerb Put -Body ($mapObject | ConvertTo-Json -Compress) } - $mapObject = New-Object -TypeName psobject -Property $mapObject - if ($Patch.IsPresent) { - #$notChanged = $mapObject | compare-object -ReferenceObject $OldObject -ExcludeDifferent -PassThru - #$mapObject = $mapObject | Select-Object -ExcludeProperty $notChanged - return Invoke-nbApi -Resource $Resource/$id -HttpVerb Patch -Body ($mapObject | ConvertTo-Json) + catch { + $PSCmdlet.ThrowTerminatingError($_) } - return Invoke-nbApi -Resource $Resource/$id -HttpVerb Put -Body ($mapObject | ConvertTo-Json) } diff --git a/module/Public/Set-nbx.ps1 b/module/Public/Set-nbx.ps1 index 57bb9f8..50ed0fc 100644 --- a/module/Public/Set-nbx.ps1 +++ b/module/Public/Set-nbx.ps1 @@ -5,7 +5,7 @@ <# .SYNOPSIS - Sets properties on a Prefix in Netbox + Sets properties on a VlanGroup in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -15,7 +15,7 @@ site='organization/sites' status='dcim/_choices' } - $Prefix = @{ + $VlanGroup = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -23,17 +23,17 @@ site = 'chicago' status = 'active' } - Set-nbPrefix -id 22 -lookup $lookup $Prefix + Set-nbVlanGroup -id 22 -lookup $lookup $VlanGroup .EXAMPLE - Get-nbPrefix | Foreach {$_.site = 'Seattle'; $_} | Set-nbPrefix + Get-nbVlanGroup | Foreach {$_.site = 'Seattle'; $_} | Set-nbVlanGroup #> -Function Set-nbPrefix { +Function Set-nbVlanGroup { Param ( - # The Prefix to set + # The VlanGroup to set [Parameter(Mandatory=$true)] $object, - # ID of the Prefix to set + # ID of the VlanGroup to set [Parameter()] [Int] $Id, @@ -53,19 +53,23 @@ Function Set-nbPrefix { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'ipam/prefixes' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'ipam/vlan-groups' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a ConsolePortTemplate in Netbox + Sets properties on a ClusterGroup in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -75,7 +79,7 @@ Function Set-nbPrefix { site='organization/sites' status='dcim/_choices' } - $ConsolePortTemplate = @{ + $ClusterGroup = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -83,17 +87,17 @@ Function Set-nbPrefix { site = 'chicago' status = 'active' } - Set-nbConsolePortTemplate -id 22 -lookup $lookup $ConsolePortTemplate + Set-nbClusterGroup -id 22 -lookup $lookup $ClusterGroup .EXAMPLE - Get-nbConsolePortTemplate | Foreach {$_.site = 'Seattle'; $_} | Set-nbConsolePortTemplate + Get-nbClusterGroup | Foreach {$_.site = 'Seattle'; $_} | Set-nbClusterGroup #> -Function Set-nbConsolePortTemplate { +Function Set-nbClusterGroup { Param ( - # The ConsolePortTemplate to set + # The ClusterGroup to set [Parameter(Mandatory=$true)] $object, - # ID of the ConsolePortTemplate to set + # ID of the ClusterGroup to set [Parameter()] [Int] $Id, @@ -113,19 +117,23 @@ Function Set-nbConsolePortTemplate { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'dcim/console-port-templates' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'virtualization/cluster-groups' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a Interface in Netbox + Sets properties on a DeviceType in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -135,7 +143,7 @@ Function Set-nbConsolePortTemplate { site='organization/sites' status='dcim/_choices' } - $Interface = @{ + $DeviceType = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -143,17 +151,17 @@ Function Set-nbConsolePortTemplate { site = 'chicago' status = 'active' } - Set-nbInterface -id 22 -lookup $lookup $Interface + Set-nbDeviceType -id 22 -lookup $lookup $DeviceType .EXAMPLE - Get-nbInterface | Foreach {$_.site = 'Seattle'; $_} | Set-nbInterface + Get-nbDeviceType | Foreach {$_.site = 'Seattle'; $_} | Set-nbDeviceType #> -Function Set-nbInterface { +Function Set-nbDeviceType { Param ( - # The Interface to set + # The DeviceType to set [Parameter(Mandatory=$true)] $object, - # ID of the Interface to set + # ID of the DeviceType to set [Parameter()] [Int] $Id, @@ -173,19 +181,23 @@ Function Set-nbInterface { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'dcim/interfaces' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'dcim/device-types' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a PowerConnection in Netbox + Sets properties on a PowerOutlet in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -195,7 +207,7 @@ Function Set-nbInterface { site='organization/sites' status='dcim/_choices' } - $PowerConnection = @{ + $PowerOutlet = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -203,17 +215,17 @@ Function Set-nbInterface { site = 'chicago' status = 'active' } - Set-nbPowerConnection -id 22 -lookup $lookup $PowerConnection + Set-nbPowerOutlet -id 22 -lookup $lookup $PowerOutlet .EXAMPLE - Get-nbPowerConnection | Foreach {$_.site = 'Seattle'; $_} | Set-nbPowerConnection + Get-nbPowerOutlet | Foreach {$_.site = 'Seattle'; $_} | Set-nbPowerOutlet #> -Function Set-nbPowerConnection { +Function Set-nbPowerOutlet { Param ( - # The PowerConnection to set + # The PowerOutlet to set [Parameter(Mandatory=$true)] $object, - # ID of the PowerConnection to set + # ID of the PowerOutlet to set [Parameter()] [Int] $Id, @@ -233,14 +245,18 @@ Function Set-nbPowerConnection { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'dcim/power-connections' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'dcim/power-outlets' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# @@ -293,19 +309,23 @@ Function Set-nbConnectedDevice { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'dcim/connected-device' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'dcim/connected-device' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a IpAddress in Netbox + Sets properties on a Region in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -315,7 +335,7 @@ Function Set-nbConnectedDevice { site='organization/sites' status='dcim/_choices' } - $IpAddress = @{ + $Region = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -323,17 +343,17 @@ Function Set-nbConnectedDevice { site = 'chicago' status = 'active' } - Set-nbIpAddress -id 22 -lookup $lookup $IpAddress + Set-nbRegion -id 22 -lookup $lookup $Region .EXAMPLE - Get-nbIpAddress | Foreach {$_.site = 'Seattle'; $_} | Set-nbIpAddress + Get-nbRegion | Foreach {$_.site = 'Seattle'; $_} | Set-nbRegion #> -Function Set-nbIpAddress { +Function Set-nbRegion { Param ( - # The IpAddress to set + # The Region to set [Parameter(Mandatory=$true)] $object, - # ID of the IpAddress to set + # ID of the Region to set [Parameter()] [Int] $Id, @@ -353,19 +373,23 @@ Function Set-nbIpAddress { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'ipam/ip-addresses' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'dcim/regions' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a Aggregate in Netbox + Sets properties on a ConsoleServerPortTemplate in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -375,7 +399,7 @@ Function Set-nbIpAddress { site='organization/sites' status='dcim/_choices' } - $Aggregate = @{ + $ConsoleServerPortTemplate = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -383,17 +407,17 @@ Function Set-nbIpAddress { site = 'chicago' status = 'active' } - Set-nbAggregate -id 22 -lookup $lookup $Aggregate + Set-nbConsoleServerPortTemplate -id 22 -lookup $lookup $ConsoleServerPortTemplate .EXAMPLE - Get-nbAggregate | Foreach {$_.site = 'Seattle'; $_} | Set-nbAggregate + Get-nbConsoleServerPortTemplate | Foreach {$_.site = 'Seattle'; $_} | Set-nbConsoleServerPortTemplate #> -Function Set-nbAggregate { +Function Set-nbConsoleServerPortTemplate { Param ( - # The Aggregate to set + # The ConsoleServerPortTemplate to set [Parameter(Mandatory=$true)] $object, - # ID of the Aggregate to set + # ID of the ConsoleServerPortTemplate to set [Parameter()] [Int] $Id, @@ -413,19 +437,23 @@ Function Set-nbAggregate { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'ipam/aggregates' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'dcim/console-server-port-templates' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a PowerPortTemplate in Netbox + Sets properties on a Aggregate in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -435,7 +463,7 @@ Function Set-nbAggregate { site='organization/sites' status='dcim/_choices' } - $PowerPortTemplate = @{ + $Aggregate = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -443,17 +471,17 @@ Function Set-nbAggregate { site = 'chicago' status = 'active' } - Set-nbPowerPortTemplate -id 22 -lookup $lookup $PowerPortTemplate + Set-nbAggregate -id 22 -lookup $lookup $Aggregate .EXAMPLE - Get-nbPowerPortTemplate | Foreach {$_.site = 'Seattle'; $_} | Set-nbPowerPortTemplate + Get-nbAggregate | Foreach {$_.site = 'Seattle'; $_} | Set-nbAggregate #> -Function Set-nbPowerPortTemplate { +Function Set-nbAggregate { Param ( - # The PowerPortTemplate to set + # The Aggregate to set [Parameter(Mandatory=$true)] $object, - # ID of the PowerPortTemplate to set + # ID of the Aggregate to set [Parameter()] [Int] $Id, @@ -473,19 +501,23 @@ Function Set-nbPowerPortTemplate { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'dcim/power-port-templates' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'ipam/aggregates' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a ImageAttachment in Netbox + Sets properties on a ClusterType in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -495,7 +527,7 @@ Function Set-nbPowerPortTemplate { site='organization/sites' status='dcim/_choices' } - $ImageAttachment = @{ + $ClusterType = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -503,17 +535,17 @@ Function Set-nbPowerPortTemplate { site = 'chicago' status = 'active' } - Set-nbImageAttachment -id 22 -lookup $lookup $ImageAttachment + Set-nbClusterType -id 22 -lookup $lookup $ClusterType .EXAMPLE - Get-nbImageAttachment | Foreach {$_.site = 'Seattle'; $_} | Set-nbImageAttachment + Get-nbClusterType | Foreach {$_.site = 'Seattle'; $_} | Set-nbClusterType #> -Function Set-nbImageAttachment { +Function Set-nbClusterType { Param ( - # The ImageAttachment to set + # The ClusterType to set [Parameter(Mandatory=$true)] $object, - # ID of the ImageAttachment to set + # ID of the ClusterType to set [Parameter()] [Int] $Id, @@ -533,19 +565,23 @@ Function Set-nbImageAttachment { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'extras/image-attachments' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'virtualization/cluster-types' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a ConsoleServerPort in Netbox + Sets properties on a Vlan in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -555,7 +591,7 @@ Function Set-nbImageAttachment { site='organization/sites' status='dcim/_choices' } - $ConsoleServerPort = @{ + $Vlan = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -563,17 +599,17 @@ Function Set-nbImageAttachment { site = 'chicago' status = 'active' } - Set-nbConsoleServerPort -id 22 -lookup $lookup $ConsoleServerPort + Set-nbVlan -id 22 -lookup $lookup $Vlan .EXAMPLE - Get-nbConsoleServerPort | Foreach {$_.site = 'Seattle'; $_} | Set-nbConsoleServerPort + Get-nbVlan | Foreach {$_.site = 'Seattle'; $_} | Set-nbVlan #> -Function Set-nbConsoleServerPort { +Function Set-nbVlan { Param ( - # The ConsoleServerPort to set + # The Vlan to set [Parameter(Mandatory=$true)] $object, - # ID of the ConsoleServerPort to set + # ID of the Vlan to set [Parameter()] [Int] $Id, @@ -593,19 +629,23 @@ Function Set-nbConsoleServerPort { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'dcim/console-server-ports' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'ipam/vlans' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a InventoryItem in Netbox + Sets properties on a Provider in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -615,7 +655,7 @@ Function Set-nbConsoleServerPort { site='organization/sites' status='dcim/_choices' } - $InventoryItem = @{ + $Provider = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -623,17 +663,17 @@ Function Set-nbConsoleServerPort { site = 'chicago' status = 'active' } - Set-nbInventoryItem -id 22 -lookup $lookup $InventoryItem + Set-nbProvider -id 22 -lookup $lookup $Provider .EXAMPLE - Get-nbInventoryItem | Foreach {$_.site = 'Seattle'; $_} | Set-nbInventoryItem + Get-nbProvider | Foreach {$_.site = 'Seattle'; $_} | Set-nbProvider #> -Function Set-nbInventoryItem { +Function Set-nbProvider { Param ( - # The InventoryItem to set + # The Provider to set [Parameter(Mandatory=$true)] $object, - # ID of the InventoryItem to set + # ID of the Provider to set [Parameter()] [Int] $Id, @@ -653,19 +693,23 @@ Function Set-nbInventoryItem { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'dcim/inventory-items' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'circuits/providers' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a Service in Netbox + Sets properties on a PowerConnection in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -675,7 +719,7 @@ Function Set-nbInventoryItem { site='organization/sites' status='dcim/_choices' } - $Service = @{ + $PowerConnection = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -683,17 +727,17 @@ Function Set-nbInventoryItem { site = 'chicago' status = 'active' } - Set-nbService -id 22 -lookup $lookup $Service + Set-nbPowerConnection -id 22 -lookup $lookup $PowerConnection .EXAMPLE - Get-nbService | Foreach {$_.site = 'Seattle'; $_} | Set-nbService + Get-nbPowerConnection | Foreach {$_.site = 'Seattle'; $_} | Set-nbPowerConnection #> -Function Set-nbService { +Function Set-nbPowerConnection { Param ( - # The Service to set + # The PowerConnection to set [Parameter(Mandatory=$true)] $object, - # ID of the Service to set + # ID of the PowerConnection to set [Parameter()] [Int] $Id, @@ -713,19 +757,23 @@ Function Set-nbService { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'ipam/services' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'dcim/power-connections' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a ConsoleServerPortTemplate in Netbox + Sets properties on a ConsolePort in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -735,7 +783,7 @@ Function Set-nbService { site='organization/sites' status='dcim/_choices' } - $ConsoleServerPortTemplate = @{ + $ConsolePort = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -743,17 +791,17 @@ Function Set-nbService { site = 'chicago' status = 'active' } - Set-nbConsoleServerPortTemplate -id 22 -lookup $lookup $ConsoleServerPortTemplate + Set-nbConsolePort -id 22 -lookup $lookup $ConsolePort .EXAMPLE - Get-nbConsoleServerPortTemplate | Foreach {$_.site = 'Seattle'; $_} | Set-nbConsoleServerPortTemplate + Get-nbConsolePort | Foreach {$_.site = 'Seattle'; $_} | Set-nbConsolePort #> -Function Set-nbConsoleServerPortTemplate { +Function Set-nbConsolePort { Param ( - # The ConsoleServerPortTemplate to set + # The ConsolePort to set [Parameter(Mandatory=$true)] $object, - # ID of the ConsoleServerPortTemplate to set + # ID of the ConsolePort to set [Parameter()] [Int] $Id, @@ -773,19 +821,23 @@ Function Set-nbConsoleServerPortTemplate { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'dcim/console-server-port-templates' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'dcim/console-ports' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a VirtualMachine in Netbox + Sets properties on a VMInterface in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -795,7 +847,7 @@ Function Set-nbConsoleServerPortTemplate { site='organization/sites' status='dcim/_choices' } - $VirtualMachine = @{ + $VMInterface = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -803,17 +855,17 @@ Function Set-nbConsoleServerPortTemplate { site = 'chicago' status = 'active' } - Set-nbVirtualMachine -id 22 -lookup $lookup $VirtualMachine + Set-nbVMInterface -id 22 -lookup $lookup $VMInterface .EXAMPLE - Get-nbVirtualMachine | Foreach {$_.site = 'Seattle'; $_} | Set-nbVirtualMachine + Get-nbVMInterface | Foreach {$_.site = 'Seattle'; $_} | Set-nbVMInterface #> -Function Set-nbVirtualMachine { +Function Set-nbVMInterface { Param ( - # The VirtualMachine to set + # The VMInterface to set [Parameter(Mandatory=$true)] $object, - # ID of the VirtualMachine to set + # ID of the VMInterface to set [Parameter()] [Int] $Id, @@ -833,19 +885,23 @@ Function Set-nbVirtualMachine { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'virtualization/virtual-machines' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'virtualization/interfaces' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a Rir in Netbox + Sets properties on a Platform in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -855,7 +911,7 @@ Function Set-nbVirtualMachine { site='organization/sites' status='dcim/_choices' } - $Rir = @{ + $Platform = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -863,17 +919,17 @@ Function Set-nbVirtualMachine { site = 'chicago' status = 'active' } - Set-nbRir -id 22 -lookup $lookup $Rir + Set-nbPlatform -id 22 -lookup $lookup $Platform .EXAMPLE - Get-nbRir | Foreach {$_.site = 'Seattle'; $_} | Set-nbRir + Get-nbPlatform | Foreach {$_.site = 'Seattle'; $_} | Set-nbPlatform #> -Function Set-nbRir { +Function Set-nbPlatform { Param ( - # The Rir to set + # The Platform to set [Parameter(Mandatory=$true)] $object, - # ID of the Rir to set + # ID of the Platform to set [Parameter()] [Int] $Id, @@ -893,19 +949,23 @@ Function Set-nbRir { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'ipam/rirs' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'dcim/platforms' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a Report in Netbox + Sets properties on a Circuit in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -915,7 +975,7 @@ Function Set-nbRir { site='organization/sites' status='dcim/_choices' } - $Report = @{ + $Circuit = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -923,17 +983,17 @@ Function Set-nbRir { site = 'chicago' status = 'active' } - Set-nbReport -id 22 -lookup $lookup $Report + Set-nbCircuit -id 22 -lookup $lookup $Circuit .EXAMPLE - Get-nbReport | Foreach {$_.site = 'Seattle'; $_} | Set-nbReport + Get-nbCircuit | Foreach {$_.site = 'Seattle'; $_} | Set-nbCircuit #> -Function Set-nbReport { +Function Set-nbCircuit { Param ( - # The Report to set + # The Circuit to set [Parameter(Mandatory=$true)] $object, - # ID of the Report to set + # ID of the Circuit to set [Parameter()] [Int] $Id, @@ -953,19 +1013,23 @@ Function Set-nbReport { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'extras/reports' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'circuits/circuits' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a TenantGroup in Netbox + Sets properties on a RackReservation in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -975,7 +1039,7 @@ Function Set-nbReport { site='organization/sites' status='dcim/_choices' } - $TenantGroup = @{ + $RackReservation = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -983,17 +1047,17 @@ Function Set-nbReport { site = 'chicago' status = 'active' } - Set-nbTenantGroup -id 22 -lookup $lookup $TenantGroup + Set-nbRackReservation -id 22 -lookup $lookup $RackReservation .EXAMPLE - Get-nbTenantGroup | Foreach {$_.site = 'Seattle'; $_} | Set-nbTenantGroup + Get-nbRackReservation | Foreach {$_.site = 'Seattle'; $_} | Set-nbRackReservation #> -Function Set-nbTenantGroup { +Function Set-nbRackReservation { Param ( - # The TenantGroup to set + # The RackReservation to set [Parameter(Mandatory=$true)] $object, - # ID of the TenantGroup to set + # ID of the RackReservation to set [Parameter()] [Int] $Id, @@ -1013,19 +1077,23 @@ Function Set-nbTenantGroup { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'tenancy/tenant-groups' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'dcim/rack-reservations' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a TopologyMap in Netbox + Sets properties on a TenantGroup in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1035,7 +1103,7 @@ Function Set-nbTenantGroup { site='organization/sites' status='dcim/_choices' } - $TopologyMap = @{ + $TenantGroup = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1043,17 +1111,17 @@ Function Set-nbTenantGroup { site = 'chicago' status = 'active' } - Set-nbTopologyMap -id 22 -lookup $lookup $TopologyMap + Set-nbTenantGroup -id 22 -lookup $lookup $TenantGroup .EXAMPLE - Get-nbTopologyMap | Foreach {$_.site = 'Seattle'; $_} | Set-nbTopologyMap + Get-nbTenantGroup | Foreach {$_.site = 'Seattle'; $_} | Set-nbTenantGroup #> -Function Set-nbTopologyMap { +Function Set-nbTenantGroup { Param ( - # The TopologyMap to set + # The TenantGroup to set [Parameter(Mandatory=$true)] $object, - # ID of the TopologyMap to set + # ID of the TenantGroup to set [Parameter()] [Int] $Id, @@ -1073,19 +1141,23 @@ Function Set-nbTopologyMap { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'extras/topology-maps' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'tenancy/tenant-groups' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a RackGroup in Netbox + Sets properties on a Devicebay in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1095,7 +1167,7 @@ Function Set-nbTopologyMap { site='organization/sites' status='dcim/_choices' } - $RackGroup = @{ + $Devicebay = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1103,17 +1175,17 @@ Function Set-nbTopologyMap { site = 'chicago' status = 'active' } - Set-nbRackGroup -id 22 -lookup $lookup $RackGroup + Set-nbDevicebay -id 22 -lookup $lookup $Devicebay .EXAMPLE - Get-nbRackGroup | Foreach {$_.site = 'Seattle'; $_} | Set-nbRackGroup + Get-nbDevicebay | Foreach {$_.site = 'Seattle'; $_} | Set-nbDevicebay #> -Function Set-nbRackGroup { +Function Set-nbDevicebay { Param ( - # The RackGroup to set + # The Devicebay to set [Parameter(Mandatory=$true)] $object, - # ID of the RackGroup to set + # ID of the Devicebay to set [Parameter()] [Int] $Id, @@ -1133,19 +1205,23 @@ Function Set-nbRackGroup { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'dcim/rack-groups' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'dcim/device-bays' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a Provider in Netbox + Sets properties on a Rir in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1155,7 +1231,7 @@ Function Set-nbRackGroup { site='organization/sites' status='dcim/_choices' } - $Provider = @{ + $Rir = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1163,17 +1239,17 @@ Function Set-nbRackGroup { site = 'chicago' status = 'active' } - Set-nbProvider -id 22 -lookup $lookup $Provider + Set-nbRir -id 22 -lookup $lookup $Rir .EXAMPLE - Get-nbProvider | Foreach {$_.site = 'Seattle'; $_} | Set-nbProvider + Get-nbRir | Foreach {$_.site = 'Seattle'; $_} | Set-nbRir #> -Function Set-nbProvider { +Function Set-nbRir { Param ( - # The Provider to set + # The Rir to set [Parameter(Mandatory=$true)] $object, - # ID of the Provider to set + # ID of the Rir to set [Parameter()] [Int] $Id, @@ -1193,19 +1269,23 @@ Function Set-nbProvider { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'circuits/providers' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'ipam/rirs' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a RackReservation in Netbox + Sets properties on a DevicebayTemplate in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1215,7 +1295,7 @@ Function Set-nbProvider { site='organization/sites' status='dcim/_choices' } - $RackReservation = @{ + $DevicebayTemplate = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1223,17 +1303,17 @@ Function Set-nbProvider { site = 'chicago' status = 'active' } - Set-nbRackReservation -id 22 -lookup $lookup $RackReservation + Set-nbDevicebayTemplate -id 22 -lookup $lookup $DevicebayTemplate .EXAMPLE - Get-nbRackReservation | Foreach {$_.site = 'Seattle'; $_} | Set-nbRackReservation + Get-nbDevicebayTemplate | Foreach {$_.site = 'Seattle'; $_} | Set-nbDevicebayTemplate #> -Function Set-nbRackReservation { +Function Set-nbDevicebayTemplate { Param ( - # The RackReservation to set + # The DevicebayTemplate to set [Parameter(Mandatory=$true)] $object, - # ID of the RackReservation to set + # ID of the DevicebayTemplate to set [Parameter()] [Int] $Id, @@ -1253,19 +1333,23 @@ Function Set-nbRackReservation { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'dcim/rack-reservations' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'dcim/device-bay-templates' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a PowerOutletTemplate in Netbox + Sets properties on a Graph in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1275,7 +1359,7 @@ Function Set-nbRackReservation { site='organization/sites' status='dcim/_choices' } - $PowerOutletTemplate = @{ + $Graph = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1283,17 +1367,17 @@ Function Set-nbRackReservation { site = 'chicago' status = 'active' } - Set-nbPowerOutletTemplate -id 22 -lookup $lookup $PowerOutletTemplate + Set-nbGraph -id 22 -lookup $lookup $Graph .EXAMPLE - Get-nbPowerOutletTemplate | Foreach {$_.site = 'Seattle'; $_} | Set-nbPowerOutletTemplate + Get-nbGraph | Foreach {$_.site = 'Seattle'; $_} | Set-nbGraph #> -Function Set-nbPowerOutletTemplate { +Function Set-nbGraph { Param ( - # The PowerOutletTemplate to set + # The Graph to set [Parameter(Mandatory=$true)] $object, - # ID of the PowerOutletTemplate to set + # ID of the Graph to set [Parameter()] [Int] $Id, @@ -1313,19 +1397,23 @@ Function Set-nbPowerOutletTemplate { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'dcim/power-outlet-templates' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'extras/graphs' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a PowerOutlet in Netbox + Sets properties on a Interface in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1335,7 +1423,7 @@ Function Set-nbPowerOutletTemplate { site='organization/sites' status='dcim/_choices' } - $PowerOutlet = @{ + $Interface = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1343,17 +1431,17 @@ Function Set-nbPowerOutletTemplate { site = 'chicago' status = 'active' } - Set-nbPowerOutlet -id 22 -lookup $lookup $PowerOutlet + Set-nbInterface -id 22 -lookup $lookup $Interface .EXAMPLE - Get-nbPowerOutlet | Foreach {$_.site = 'Seattle'; $_} | Set-nbPowerOutlet + Get-nbInterface | Foreach {$_.site = 'Seattle'; $_} | Set-nbInterface #> -Function Set-nbPowerOutlet { +Function Set-nbInterface { Param ( - # The PowerOutlet to set + # The Interface to set [Parameter(Mandatory=$true)] $object, - # ID of the PowerOutlet to set + # ID of the Interface to set [Parameter()] [Int] $Id, @@ -1373,19 +1461,23 @@ Function Set-nbPowerOutlet { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'dcim/power-outlets' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'dcim/interfaces' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a Circuit in Netbox + Sets properties on a InterfaceConnection in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1395,7 +1487,7 @@ Function Set-nbPowerOutlet { site='organization/sites' status='dcim/_choices' } - $Circuit = @{ + $InterfaceConnection = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1403,17 +1495,17 @@ Function Set-nbPowerOutlet { site = 'chicago' status = 'active' } - Set-nbCircuit -id 22 -lookup $lookup $Circuit + Set-nbInterfaceConnection -id 22 -lookup $lookup $InterfaceConnection .EXAMPLE - Get-nbCircuit | Foreach {$_.site = 'Seattle'; $_} | Set-nbCircuit + Get-nbInterfaceConnection | Foreach {$_.site = 'Seattle'; $_} | Set-nbInterfaceConnection #> -Function Set-nbCircuit { +Function Set-nbInterfaceConnection { Param ( - # The Circuit to set + # The InterfaceConnection to set [Parameter(Mandatory=$true)] $object, - # ID of the Circuit to set + # ID of the InterfaceConnection to set [Parameter()] [Int] $Id, @@ -1433,19 +1525,23 @@ Function Set-nbCircuit { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'circuits/circuits' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'dcim/interface-connections' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a Graph in Netbox + Sets properties on a Role in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1455,7 +1551,7 @@ Function Set-nbCircuit { site='organization/sites' status='dcim/_choices' } - $Graph = @{ + $Role = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1463,17 +1559,17 @@ Function Set-nbCircuit { site = 'chicago' status = 'active' } - Set-nbGraph -id 22 -lookup $lookup $Graph + Set-nbRole -id 22 -lookup $lookup $Role .EXAMPLE - Get-nbGraph | Foreach {$_.site = 'Seattle'; $_} | Set-nbGraph + Get-nbRole | Foreach {$_.site = 'Seattle'; $_} | Set-nbRole #> -Function Set-nbGraph { +Function Set-nbRole { Param ( - # The Graph to set + # The Role to set [Parameter(Mandatory=$true)] $object, - # ID of the Graph to set + # ID of the Role to set [Parameter()] [Int] $Id, @@ -1493,19 +1589,23 @@ Function Set-nbGraph { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'extras/graphs' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'ipam/roles' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a Device in Netbox + Sets properties on a ImageAttachment in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1515,7 +1615,7 @@ Function Set-nbGraph { site='organization/sites' status='dcim/_choices' } - $Device = @{ + $ImageAttachment = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1523,17 +1623,17 @@ Function Set-nbGraph { site = 'chicago' status = 'active' } - Set-nbDevice -id 22 -lookup $lookup $Device + Set-nbImageAttachment -id 22 -lookup $lookup $ImageAttachment .EXAMPLE - Get-nbDevice | Foreach {$_.site = 'Seattle'; $_} | Set-nbDevice + Get-nbImageAttachment | Foreach {$_.site = 'Seattle'; $_} | Set-nbImageAttachment #> -Function Set-nbDevice { +Function Set-nbImageAttachment { Param ( - # The Device to set + # The ImageAttachment to set [Parameter(Mandatory=$true)] $object, - # ID of the Device to set + # ID of the ImageAttachment to set [Parameter()] [Int] $Id, @@ -1553,19 +1653,23 @@ Function Set-nbDevice { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'dcim/devices' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'extras/image-attachments' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a VirtualChassis in Netbox + Sets properties on a Rack in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1575,7 +1679,7 @@ Function Set-nbDevice { site='organization/sites' status='dcim/_choices' } - $VirtualChassis = @{ + $Rack = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1583,17 +1687,17 @@ Function Set-nbDevice { site = 'chicago' status = 'active' } - Set-nbVirtualChassis -id 22 -lookup $lookup $VirtualChassis + Set-nbRack -id 22 -lookup $lookup $Rack .EXAMPLE - Get-nbVirtualChassis | Foreach {$_.site = 'Seattle'; $_} | Set-nbVirtualChassis + Get-nbRack | Foreach {$_.site = 'Seattle'; $_} | Set-nbRack #> -Function Set-nbVirtualChassis { +Function Set-nbRack { Param ( - # The VirtualChassis to set + # The Rack to set [Parameter(Mandatory=$true)] $object, - # ID of the VirtualChassis to set + # ID of the Rack to set [Parameter()] [Int] $Id, @@ -1613,19 +1717,23 @@ Function Set-nbVirtualChassis { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'dcim/virtual-chassis' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'dcim/racks' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a DevicebayTemplate in Netbox + Sets properties on a ConsolePortTemplate in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1635,7 +1743,7 @@ Function Set-nbVirtualChassis { site='organization/sites' status='dcim/_choices' } - $DevicebayTemplate = @{ + $ConsolePortTemplate = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1643,17 +1751,17 @@ Function Set-nbVirtualChassis { site = 'chicago' status = 'active' } - Set-nbDevicebayTemplate -id 22 -lookup $lookup $DevicebayTemplate + Set-nbConsolePortTemplate -id 22 -lookup $lookup $ConsolePortTemplate .EXAMPLE - Get-nbDevicebayTemplate | Foreach {$_.site = 'Seattle'; $_} | Set-nbDevicebayTemplate + Get-nbConsolePortTemplate | Foreach {$_.site = 'Seattle'; $_} | Set-nbConsolePortTemplate #> -Function Set-nbDevicebayTemplate { +Function Set-nbConsolePortTemplate { Param ( - # The DevicebayTemplate to set + # The ConsolePortTemplate to set [Parameter(Mandatory=$true)] $object, - # ID of the DevicebayTemplate to set + # ID of the ConsolePortTemplate to set [Parameter()] [Int] $Id, @@ -1673,19 +1781,23 @@ Function Set-nbDevicebayTemplate { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'dcim/device-bay-templates' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'dcim/console-port-templates' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a ConsoleConnection in Netbox + Sets properties on a InterfaceTemplate in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1695,7 +1807,7 @@ Function Set-nbDevicebayTemplate { site='organization/sites' status='dcim/_choices' } - $ConsoleConnection = @{ + $InterfaceTemplate = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1703,17 +1815,17 @@ Function Set-nbDevicebayTemplate { site = 'chicago' status = 'active' } - Set-nbConsoleConnection -id 22 -lookup $lookup $ConsoleConnection + Set-nbInterfaceTemplate -id 22 -lookup $lookup $InterfaceTemplate .EXAMPLE - Get-nbConsoleConnection | Foreach {$_.site = 'Seattle'; $_} | Set-nbConsoleConnection + Get-nbInterfaceTemplate | Foreach {$_.site = 'Seattle'; $_} | Set-nbInterfaceTemplate #> -Function Set-nbConsoleConnection { +Function Set-nbInterfaceTemplate { Param ( - # The ConsoleConnection to set + # The InterfaceTemplate to set [Parameter(Mandatory=$true)] $object, - # ID of the ConsoleConnection to set + # ID of the InterfaceTemplate to set [Parameter()] [Int] $Id, @@ -1733,19 +1845,23 @@ Function Set-nbConsoleConnection { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'dcim/console-connections' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'dcim/interface-templates' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a RackRole in Netbox + Sets properties on a ExportTemplate in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1755,7 +1871,7 @@ Function Set-nbConsoleConnection { site='organization/sites' status='dcim/_choices' } - $RackRole = @{ + $ExportTemplate = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1763,17 +1879,17 @@ Function Set-nbConsoleConnection { site = 'chicago' status = 'active' } - Set-nbRackRole -id 22 -lookup $lookup $RackRole + Set-nbExportTemplate -id 22 -lookup $lookup $ExportTemplate .EXAMPLE - Get-nbRackRole | Foreach {$_.site = 'Seattle'; $_} | Set-nbRackRole + Get-nbExportTemplate | Foreach {$_.site = 'Seattle'; $_} | Set-nbExportTemplate #> -Function Set-nbRackRole { +Function Set-nbExportTemplate { Param ( - # The RackRole to set + # The ExportTemplate to set [Parameter(Mandatory=$true)] $object, - # ID of the RackRole to set + # ID of the ExportTemplate to set [Parameter()] [Int] $Id, @@ -1793,19 +1909,23 @@ Function Set-nbRackRole { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'dcim/rack-roles' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'extras/export-templates' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a Platform in Netbox + Sets properties on a Cluster in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1815,7 +1935,7 @@ Function Set-nbRackRole { site='organization/sites' status='dcim/_choices' } - $Platform = @{ + $Cluster = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1823,17 +1943,17 @@ Function Set-nbRackRole { site = 'chicago' status = 'active' } - Set-nbPlatform -id 22 -lookup $lookup $Platform + Set-nbCluster -id 22 -lookup $lookup $Cluster .EXAMPLE - Get-nbPlatform | Foreach {$_.site = 'Seattle'; $_} | Set-nbPlatform + Get-nbCluster | Foreach {$_.site = 'Seattle'; $_} | Set-nbCluster #> -Function Set-nbPlatform { +Function Set-nbCluster { Param ( - # The Platform to set + # The Cluster to set [Parameter(Mandatory=$true)] $object, - # ID of the Platform to set + # ID of the Cluster to set [Parameter()] [Int] $Id, @@ -1853,19 +1973,23 @@ Function Set-nbPlatform { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'dcim/platforms' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'virtualization/clusters' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a Vlan in Netbox + Sets properties on a Service in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1875,7 +1999,7 @@ Function Set-nbPlatform { site='organization/sites' status='dcim/_choices' } - $Vlan = @{ + $Service = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1883,17 +2007,17 @@ Function Set-nbPlatform { site = 'chicago' status = 'active' } - Set-nbVlan -id 22 -lookup $lookup $Vlan + Set-nbService -id 22 -lookup $lookup $Service .EXAMPLE - Get-nbVlan | Foreach {$_.site = 'Seattle'; $_} | Set-nbVlan + Get-nbService | Foreach {$_.site = 'Seattle'; $_} | Set-nbService #> -Function Set-nbVlan { +Function Set-nbService { Param ( - # The Vlan to set + # The Service to set [Parameter(Mandatory=$true)] $object, - # ID of the Vlan to set + # ID of the Service to set [Parameter()] [Int] $Id, @@ -1913,19 +2037,23 @@ Function Set-nbVlan { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'ipam/vlans' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'ipam/services' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a RecentActivity in Netbox + Sets properties on a RackRole in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1935,7 +2063,7 @@ Function Set-nbVlan { site='organization/sites' status='dcim/_choices' } - $RecentActivity = @{ + $RackRole = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -1943,17 +2071,17 @@ Function Set-nbVlan { site = 'chicago' status = 'active' } - Set-nbRecentActivity -id 22 -lookup $lookup $RecentActivity + Set-nbRackRole -id 22 -lookup $lookup $RackRole .EXAMPLE - Get-nbRecentActivity | Foreach {$_.site = 'Seattle'; $_} | Set-nbRecentActivity + Get-nbRackRole | Foreach {$_.site = 'Seattle'; $_} | Set-nbRackRole #> -Function Set-nbRecentActivity { +Function Set-nbRackRole { Param ( - # The RecentActivity to set + # The RackRole to set [Parameter(Mandatory=$true)] $object, - # ID of the RecentActivity to set + # ID of the RackRole to set [Parameter()] [Int] $Id, @@ -1973,19 +2101,23 @@ Function Set-nbRecentActivity { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'extras/recent-activity' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'dcim/rack-roles' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a Region in Netbox + Sets properties on a CircuitType in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -1995,7 +2127,7 @@ Function Set-nbRecentActivity { site='organization/sites' status='dcim/_choices' } - $Region = @{ + $CircuitType = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -2003,17 +2135,17 @@ Function Set-nbRecentActivity { site = 'chicago' status = 'active' } - Set-nbRegion -id 22 -lookup $lookup $Region + Set-nbCircuitType -id 22 -lookup $lookup $CircuitType .EXAMPLE - Get-nbRegion | Foreach {$_.site = 'Seattle'; $_} | Set-nbRegion + Get-nbCircuitType | Foreach {$_.site = 'Seattle'; $_} | Set-nbCircuitType #> -Function Set-nbRegion { +Function Set-nbCircuitType { Param ( - # The Region to set + # The CircuitType to set [Parameter(Mandatory=$true)] $object, - # ID of the Region to set + # ID of the CircuitType to set [Parameter()] [Int] $Id, @@ -2033,19 +2165,23 @@ Function Set-nbRegion { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'dcim/regions' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'circuits/circuit-types' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a Manufacturer in Netbox + Sets properties on a Report in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -2055,7 +2191,7 @@ Function Set-nbRegion { site='organization/sites' status='dcim/_choices' } - $Manufacturer = @{ + $Report = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -2063,17 +2199,17 @@ Function Set-nbRegion { site = 'chicago' status = 'active' } - Set-nbManufacturer -id 22 -lookup $lookup $Manufacturer + Set-nbReport -id 22 -lookup $lookup $Report .EXAMPLE - Get-nbManufacturer | Foreach {$_.site = 'Seattle'; $_} | Set-nbManufacturer + Get-nbReport | Foreach {$_.site = 'Seattle'; $_} | Set-nbReport #> -Function Set-nbManufacturer { +Function Set-nbReport { Param ( - # The Manufacturer to set + # The Report to set [Parameter(Mandatory=$true)] $object, - # ID of the Manufacturer to set + # ID of the Report to set [Parameter()] [Int] $Id, @@ -2093,19 +2229,23 @@ Function Set-nbManufacturer { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'dcim/manufacturers' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'extras/reports' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a VlanGroup in Netbox + Sets properties on a Manufacturer in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -2115,7 +2255,7 @@ Function Set-nbManufacturer { site='organization/sites' status='dcim/_choices' } - $VlanGroup = @{ + $Manufacturer = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -2123,17 +2263,17 @@ Function Set-nbManufacturer { site = 'chicago' status = 'active' } - Set-nbVlanGroup -id 22 -lookup $lookup $VlanGroup + Set-nbManufacturer -id 22 -lookup $lookup $Manufacturer .EXAMPLE - Get-nbVlanGroup | Foreach {$_.site = 'Seattle'; $_} | Set-nbVlanGroup + Get-nbManufacturer | Foreach {$_.site = 'Seattle'; $_} | Set-nbManufacturer #> -Function Set-nbVlanGroup { +Function Set-nbManufacturer { Param ( - # The VlanGroup to set + # The Manufacturer to set [Parameter(Mandatory=$true)] $object, - # ID of the VlanGroup to set + # ID of the Manufacturer to set [Parameter()] [Int] $Id, @@ -2153,19 +2293,23 @@ Function Set-nbVlanGroup { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'ipam/vlan-groups' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'dcim/manufacturers' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a Tenant in Netbox + Sets properties on a RackGroup in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -2175,7 +2319,7 @@ Function Set-nbVlanGroup { site='organization/sites' status='dcim/_choices' } - $Tenant = @{ + $RackGroup = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -2183,17 +2327,17 @@ Function Set-nbVlanGroup { site = 'chicago' status = 'active' } - Set-nbTenant -id 22 -lookup $lookup $Tenant + Set-nbRackGroup -id 22 -lookup $lookup $RackGroup .EXAMPLE - Get-nbTenant | Foreach {$_.site = 'Seattle'; $_} | Set-nbTenant + Get-nbRackGroup | Foreach {$_.site = 'Seattle'; $_} | Set-nbRackGroup #> -Function Set-nbTenant { +Function Set-nbRackGroup { Param ( - # The Tenant to set + # The RackGroup to set [Parameter(Mandatory=$true)] $object, - # ID of the Tenant to set + # ID of the RackGroup to set [Parameter()] [Int] $Id, @@ -2213,19 +2357,23 @@ Function Set-nbTenant { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'tenancy/tenants' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'dcim/rack-groups' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a DeviceType in Netbox + Sets properties on a IpAddress in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -2235,7 +2383,7 @@ Function Set-nbTenant { site='organization/sites' status='dcim/_choices' } - $DeviceType = @{ + $IpAddress = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -2243,17 +2391,17 @@ Function Set-nbTenant { site = 'chicago' status = 'active' } - Set-nbDeviceType -id 22 -lookup $lookup $DeviceType + Set-nbIpAddress -id 22 -lookup $lookup $IpAddress .EXAMPLE - Get-nbDeviceType | Foreach {$_.site = 'Seattle'; $_} | Set-nbDeviceType + Get-nbIpAddress | Foreach {$_.site = 'Seattle'; $_} | Set-nbIpAddress #> -Function Set-nbDeviceType { +Function Set-nbIpAddress { Param ( - # The DeviceType to set + # The IpAddress to set [Parameter(Mandatory=$true)] $object, - # ID of the DeviceType to set + # ID of the IpAddress to set [Parameter()] [Int] $Id, @@ -2273,19 +2421,23 @@ Function Set-nbDeviceType { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'dcim/device-types' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'ipam/ip-addresses' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a CircuitTermination in Netbox + Sets properties on a Vrf in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -2295,7 +2447,7 @@ Function Set-nbDeviceType { site='organization/sites' status='dcim/_choices' } - $CircuitTermination = @{ + $Vrf = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -2303,17 +2455,17 @@ Function Set-nbDeviceType { site = 'chicago' status = 'active' } - Set-nbCircuitTermination -id 22 -lookup $lookup $CircuitTermination + Set-nbVrf -id 22 -lookup $lookup $Vrf .EXAMPLE - Get-nbCircuitTermination | Foreach {$_.site = 'Seattle'; $_} | Set-nbCircuitTermination + Get-nbVrf | Foreach {$_.site = 'Seattle'; $_} | Set-nbVrf #> -Function Set-nbCircuitTermination { +Function Set-nbVrf { Param ( - # The CircuitTermination to set + # The Vrf to set [Parameter(Mandatory=$true)] $object, - # ID of the CircuitTermination to set + # ID of the Vrf to set [Parameter()] [Int] $Id, @@ -2333,19 +2485,23 @@ Function Set-nbCircuitTermination { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'circuits/circuit-terminations' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'ipam/vrfs' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a ClusterType in Netbox + Sets properties on a Device in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -2355,7 +2511,7 @@ Function Set-nbCircuitTermination { site='organization/sites' status='dcim/_choices' } - $ClusterType = @{ + $Device = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -2363,17 +2519,17 @@ Function Set-nbCircuitTermination { site = 'chicago' status = 'active' } - Set-nbClusterType -id 22 -lookup $lookup $ClusterType + Set-nbDevice -id 22 -lookup $lookup $Device .EXAMPLE - Get-nbClusterType | Foreach {$_.site = 'Seattle'; $_} | Set-nbClusterType + Get-nbDevice | Foreach {$_.site = 'Seattle'; $_} | Set-nbDevice #> -Function Set-nbClusterType { +Function Set-nbDevice { Param ( - # The ClusterType to set + # The Device to set [Parameter(Mandatory=$true)] $object, - # ID of the ClusterType to set + # ID of the Device to set [Parameter()] [Int] $Id, @@ -2393,19 +2549,23 @@ Function Set-nbClusterType { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'virtualization/cluster-types' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'dcim/devices' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a PowerPort in Netbox + Sets properties on a Tenant in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -2415,7 +2575,7 @@ Function Set-nbClusterType { site='organization/sites' status='dcim/_choices' } - $PowerPort = @{ + $Tenant = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -2423,17 +2583,17 @@ Function Set-nbClusterType { site = 'chicago' status = 'active' } - Set-nbPowerPort -id 22 -lookup $lookup $PowerPort + Set-nbTenant -id 22 -lookup $lookup $Tenant .EXAMPLE - Get-nbPowerPort | Foreach {$_.site = 'Seattle'; $_} | Set-nbPowerPort + Get-nbTenant | Foreach {$_.site = 'Seattle'; $_} | Set-nbTenant #> -Function Set-nbPowerPort { +Function Set-nbTenant { Param ( - # The PowerPort to set + # The Tenant to set [Parameter(Mandatory=$true)] $object, - # ID of the PowerPort to set + # ID of the Tenant to set [Parameter()] [Int] $Id, @@ -2453,19 +2613,23 @@ Function Set-nbPowerPort { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'dcim/power-ports' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'tenancy/tenants' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a Role in Netbox + Sets properties on a PowerOutletTemplate in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -2475,7 +2639,7 @@ Function Set-nbPowerPort { site='organization/sites' status='dcim/_choices' } - $Role = @{ + $PowerOutletTemplate = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -2483,17 +2647,17 @@ Function Set-nbPowerPort { site = 'chicago' status = 'active' } - Set-nbRole -id 22 -lookup $lookup $Role + Set-nbPowerOutletTemplate -id 22 -lookup $lookup $PowerOutletTemplate .EXAMPLE - Get-nbRole | Foreach {$_.site = 'Seattle'; $_} | Set-nbRole + Get-nbPowerOutletTemplate | Foreach {$_.site = 'Seattle'; $_} | Set-nbPowerOutletTemplate #> -Function Set-nbRole { +Function Set-nbPowerOutletTemplate { Param ( - # The Role to set + # The PowerOutletTemplate to set [Parameter(Mandatory=$true)] $object, - # ID of the Role to set + # ID of the PowerOutletTemplate to set [Parameter()] [Int] $Id, @@ -2513,19 +2677,23 @@ Function Set-nbRole { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'ipam/roles' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'dcim/power-outlet-templates' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a Vrf in Netbox + Sets properties on a InventoryItem in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -2535,7 +2703,7 @@ Function Set-nbRole { site='organization/sites' status='dcim/_choices' } - $Vrf = @{ + $InventoryItem = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -2543,17 +2711,17 @@ Function Set-nbRole { site = 'chicago' status = 'active' } - Set-nbVrf -id 22 -lookup $lookup $Vrf + Set-nbInventoryItem -id 22 -lookup $lookup $InventoryItem .EXAMPLE - Get-nbVrf | Foreach {$_.site = 'Seattle'; $_} | Set-nbVrf + Get-nbInventoryItem | Foreach {$_.site = 'Seattle'; $_} | Set-nbInventoryItem #> -Function Set-nbVrf { +Function Set-nbInventoryItem { Param ( - # The Vrf to set + # The InventoryItem to set [Parameter(Mandatory=$true)] $object, - # ID of the Vrf to set + # ID of the InventoryItem to set [Parameter()] [Int] $Id, @@ -2573,19 +2741,23 @@ Function Set-nbVrf { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'ipam/vrfs' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'dcim/inventory-items' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a Rack in Netbox + Sets properties on a ConsoleServerPort in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -2595,7 +2767,7 @@ Function Set-nbVrf { site='organization/sites' status='dcim/_choices' } - $Rack = @{ + $ConsoleServerPort = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -2603,17 +2775,17 @@ Function Set-nbVrf { site = 'chicago' status = 'active' } - Set-nbRack -id 22 -lookup $lookup $Rack + Set-nbConsoleServerPort -id 22 -lookup $lookup $ConsoleServerPort .EXAMPLE - Get-nbRack | Foreach {$_.site = 'Seattle'; $_} | Set-nbRack + Get-nbConsoleServerPort | Foreach {$_.site = 'Seattle'; $_} | Set-nbConsoleServerPort #> -Function Set-nbRack { +Function Set-nbConsoleServerPort { Param ( - # The Rack to set + # The ConsoleServerPort to set [Parameter(Mandatory=$true)] $object, - # ID of the Rack to set + # ID of the ConsoleServerPort to set [Parameter()] [Int] $Id, @@ -2633,19 +2805,23 @@ Function Set-nbRack { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'dcim/racks' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'dcim/console-server-ports' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a Cluster in Netbox + Sets properties on a VirtualChassis in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -2655,7 +2831,7 @@ Function Set-nbRack { site='organization/sites' status='dcim/_choices' } - $Cluster = @{ + $VirtualChassis = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -2663,17 +2839,17 @@ Function Set-nbRack { site = 'chicago' status = 'active' } - Set-nbCluster -id 22 -lookup $lookup $Cluster + Set-nbVirtualChassis -id 22 -lookup $lookup $VirtualChassis .EXAMPLE - Get-nbCluster | Foreach {$_.site = 'Seattle'; $_} | Set-nbCluster + Get-nbVirtualChassis | Foreach {$_.site = 'Seattle'; $_} | Set-nbVirtualChassis #> -Function Set-nbCluster { +Function Set-nbVirtualChassis { Param ( - # The Cluster to set + # The VirtualChassis to set [Parameter(Mandatory=$true)] $object, - # ID of the Cluster to set + # ID of the VirtualChassis to set [Parameter()] [Int] $Id, @@ -2693,19 +2869,23 @@ Function Set-nbCluster { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'virtualization/clusters' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'dcim/virtual-chassis' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a Site in Netbox + Sets properties on a VirtualMachine in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -2715,7 +2895,7 @@ Function Set-nbCluster { site='organization/sites' status='dcim/_choices' } - $Site = @{ + $VirtualMachine = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -2723,17 +2903,17 @@ Function Set-nbCluster { site = 'chicago' status = 'active' } - Set-nbSite -id 22 -lookup $lookup $Site + Set-nbVirtualMachine -id 22 -lookup $lookup $VirtualMachine .EXAMPLE - Get-nbSite | Foreach {$_.site = 'Seattle'; $_} | Set-nbSite + Get-nbVirtualMachine | Foreach {$_.site = 'Seattle'; $_} | Set-nbVirtualMachine #> -Function Set-nbSite { +Function Set-nbVirtualMachine { Param ( - # The Site to set + # The VirtualMachine to set [Parameter(Mandatory=$true)] $object, - # ID of the Site to set + # ID of the VirtualMachine to set [Parameter()] [Int] $Id, @@ -2753,19 +2933,23 @@ Function Set-nbSite { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'dcim/sites' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'virtualization/virtual-machines' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a ClusterGroup in Netbox + Sets properties on a PowerPort in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -2775,7 +2959,7 @@ Function Set-nbSite { site='organization/sites' status='dcim/_choices' } - $ClusterGroup = @{ + $PowerPort = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -2783,17 +2967,17 @@ Function Set-nbSite { site = 'chicago' status = 'active' } - Set-nbClusterGroup -id 22 -lookup $lookup $ClusterGroup + Set-nbPowerPort -id 22 -lookup $lookup $PowerPort .EXAMPLE - Get-nbClusterGroup | Foreach {$_.site = 'Seattle'; $_} | Set-nbClusterGroup + Get-nbPowerPort | Foreach {$_.site = 'Seattle'; $_} | Set-nbPowerPort #> -Function Set-nbClusterGroup { +Function Set-nbPowerPort { Param ( - # The ClusterGroup to set + # The PowerPort to set [Parameter(Mandatory=$true)] $object, - # ID of the ClusterGroup to set + # ID of the PowerPort to set [Parameter()] [Int] $Id, @@ -2813,19 +2997,23 @@ Function Set-nbClusterGroup { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'virtualization/cluster-groups' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'dcim/power-ports' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a InterfaceConnection in Netbox + Sets properties on a PowerPortTemplate in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -2835,7 +3023,7 @@ Function Set-nbClusterGroup { site='organization/sites' status='dcim/_choices' } - $InterfaceConnection = @{ + $PowerPortTemplate = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -2843,17 +3031,17 @@ Function Set-nbClusterGroup { site = 'chicago' status = 'active' } - Set-nbInterfaceConnection -id 22 -lookup $lookup $InterfaceConnection + Set-nbPowerPortTemplate -id 22 -lookup $lookup $PowerPortTemplate .EXAMPLE - Get-nbInterfaceConnection | Foreach {$_.site = 'Seattle'; $_} | Set-nbInterfaceConnection + Get-nbPowerPortTemplate | Foreach {$_.site = 'Seattle'; $_} | Set-nbPowerPortTemplate #> -Function Set-nbInterfaceConnection { +Function Set-nbPowerPortTemplate { Param ( - # The InterfaceConnection to set + # The PowerPortTemplate to set [Parameter(Mandatory=$true)] $object, - # ID of the InterfaceConnection to set + # ID of the PowerPortTemplate to set [Parameter()] [Int] $Id, @@ -2873,19 +3061,23 @@ Function Set-nbInterfaceConnection { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'dcim/interface-connections' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'dcim/power-port-templates' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a CircuitType in Netbox + Sets properties on a ConsoleConnection in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -2895,7 +3087,7 @@ Function Set-nbInterfaceConnection { site='organization/sites' status='dcim/_choices' } - $CircuitType = @{ + $ConsoleConnection = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -2903,17 +3095,17 @@ Function Set-nbInterfaceConnection { site = 'chicago' status = 'active' } - Set-nbCircuitType -id 22 -lookup $lookup $CircuitType + Set-nbConsoleConnection -id 22 -lookup $lookup $ConsoleConnection .EXAMPLE - Get-nbCircuitType | Foreach {$_.site = 'Seattle'; $_} | Set-nbCircuitType + Get-nbConsoleConnection | Foreach {$_.site = 'Seattle'; $_} | Set-nbConsoleConnection #> -Function Set-nbCircuitType { +Function Set-nbConsoleConnection { Param ( - # The CircuitType to set + # The ConsoleConnection to set [Parameter(Mandatory=$true)] $object, - # ID of the CircuitType to set + # ID of the ConsoleConnection to set [Parameter()] [Int] $Id, @@ -2933,19 +3125,23 @@ Function Set-nbCircuitType { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'circuits/circuit-types' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'dcim/console-connections' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a DeviceRole in Netbox + Sets properties on a TopologyMap in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -2955,7 +3151,7 @@ Function Set-nbCircuitType { site='organization/sites' status='dcim/_choices' } - $DeviceRole = @{ + $TopologyMap = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -2963,17 +3159,17 @@ Function Set-nbCircuitType { site = 'chicago' status = 'active' } - Set-nbDeviceRole -id 22 -lookup $lookup $DeviceRole + Set-nbTopologyMap -id 22 -lookup $lookup $TopologyMap .EXAMPLE - Get-nbDeviceRole | Foreach {$_.site = 'Seattle'; $_} | Set-nbDeviceRole + Get-nbTopologyMap | Foreach {$_.site = 'Seattle'; $_} | Set-nbTopologyMap #> -Function Set-nbDeviceRole { +Function Set-nbTopologyMap { Param ( - # The DeviceRole to set + # The TopologyMap to set [Parameter(Mandatory=$true)] $object, - # ID of the DeviceRole to set + # ID of the TopologyMap to set [Parameter()] [Int] $Id, @@ -2993,19 +3189,23 @@ Function Set-nbDeviceRole { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'dcim/device-roles' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'extras/topology-maps' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a VMInterface in Netbox + Sets properties on a CircuitTermination in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -3015,7 +3215,7 @@ Function Set-nbDeviceRole { site='organization/sites' status='dcim/_choices' } - $VMInterface = @{ + $CircuitTermination = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -3023,17 +3223,17 @@ Function Set-nbDeviceRole { site = 'chicago' status = 'active' } - Set-nbVMInterface -id 22 -lookup $lookup $VMInterface + Set-nbCircuitTermination -id 22 -lookup $lookup $CircuitTermination .EXAMPLE - Get-nbVMInterface | Foreach {$_.site = 'Seattle'; $_} | Set-nbVMInterface + Get-nbCircuitTermination | Foreach {$_.site = 'Seattle'; $_} | Set-nbCircuitTermination #> -Function Set-nbVMInterface { +Function Set-nbCircuitTermination { Param ( - # The VMInterface to set + # The CircuitTermination to set [Parameter(Mandatory=$true)] $object, - # ID of the VMInterface to set + # ID of the CircuitTermination to set [Parameter()] [Int] $Id, @@ -3053,19 +3253,23 @@ Function Set-nbVMInterface { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'virtualization/interfaces' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'circuits/circuit-terminations' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a ConsolePort in Netbox + Sets properties on a RecentActivity in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -3075,7 +3279,7 @@ Function Set-nbVMInterface { site='organization/sites' status='dcim/_choices' } - $ConsolePort = @{ + $RecentActivity = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -3083,17 +3287,17 @@ Function Set-nbVMInterface { site = 'chicago' status = 'active' } - Set-nbConsolePort -id 22 -lookup $lookup $ConsolePort + Set-nbRecentActivity -id 22 -lookup $lookup $RecentActivity .EXAMPLE - Get-nbConsolePort | Foreach {$_.site = 'Seattle'; $_} | Set-nbConsolePort + Get-nbRecentActivity | Foreach {$_.site = 'Seattle'; $_} | Set-nbRecentActivity #> -Function Set-nbConsolePort { +Function Set-nbRecentActivity { Param ( - # The ConsolePort to set + # The RecentActivity to set [Parameter(Mandatory=$true)] $object, - # ID of the ConsolePort to set + # ID of the RecentActivity to set [Parameter()] [Int] $Id, @@ -3113,19 +3317,23 @@ Function Set-nbConsolePort { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'dcim/console-ports' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'extras/recent-activity' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a Devicebay in Netbox + Sets properties on a Prefix in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -3135,7 +3343,7 @@ Function Set-nbConsolePort { site='organization/sites' status='dcim/_choices' } - $Devicebay = @{ + $Prefix = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -3143,17 +3351,17 @@ Function Set-nbConsolePort { site = 'chicago' status = 'active' } - Set-nbDevicebay -id 22 -lookup $lookup $Devicebay + Set-nbPrefix -id 22 -lookup $lookup $Prefix .EXAMPLE - Get-nbDevicebay | Foreach {$_.site = 'Seattle'; $_} | Set-nbDevicebay + Get-nbPrefix | Foreach {$_.site = 'Seattle'; $_} | Set-nbPrefix #> -Function Set-nbDevicebay { +Function Set-nbPrefix { Param ( - # The Devicebay to set + # The Prefix to set [Parameter(Mandatory=$true)] $object, - # ID of the Devicebay to set + # ID of the Prefix to set [Parameter()] [Int] $Id, @@ -3173,19 +3381,23 @@ Function Set-nbDevicebay { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'dcim/device-bays' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'ipam/prefixes' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a InterfaceTemplate in Netbox + Sets properties on a DeviceRole in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -3195,7 +3407,7 @@ Function Set-nbDevicebay { site='organization/sites' status='dcim/_choices' } - $InterfaceTemplate = @{ + $DeviceRole = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -3203,17 +3415,17 @@ Function Set-nbDevicebay { site = 'chicago' status = 'active' } - Set-nbInterfaceTemplate -id 22 -lookup $lookup $InterfaceTemplate + Set-nbDeviceRole -id 22 -lookup $lookup $DeviceRole .EXAMPLE - Get-nbInterfaceTemplate | Foreach {$_.site = 'Seattle'; $_} | Set-nbInterfaceTemplate + Get-nbDeviceRole | Foreach {$_.site = 'Seattle'; $_} | Set-nbDeviceRole #> -Function Set-nbInterfaceTemplate { +Function Set-nbDeviceRole { Param ( - # The InterfaceTemplate to set + # The DeviceRole to set [Parameter(Mandatory=$true)] $object, - # ID of the InterfaceTemplate to set + # ID of the DeviceRole to set [Parameter()] [Int] $Id, @@ -3233,19 +3445,23 @@ Function Set-nbInterfaceTemplate { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'dcim/interface-templates' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'dcim/device-roles' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } <# .SYNOPSIS - Sets properties on a ExportTemplate in Netbox + Sets properties on a Site in Netbox .DESCRIPTION This should handle mapping a simple hashtable of values and looking up any references. .EXAMPLE @@ -3255,7 +3471,7 @@ Function Set-nbInterfaceTemplate { site='organization/sites' status='dcim/_choices' } - $ExportTemplate = @{ + $Site = @{ name = 'example' serial = 'aka123457' device_type = 'dl380-g9' @@ -3263,17 +3479,17 @@ Function Set-nbInterfaceTemplate { site = 'chicago' status = 'active' } - Set-nbExportTemplate -id 22 -lookup $lookup $ExportTemplate + Set-nbSite -id 22 -lookup $lookup $Site .EXAMPLE - Get-nbExportTemplate | Foreach {$_.site = 'Seattle'; $_} | Set-nbExportTemplate + Get-nbSite | Foreach {$_.site = 'Seattle'; $_} | Set-nbSite #> -Function Set-nbExportTemplate { +Function Set-nbSite { Param ( - # The ExportTemplate to set + # The Site to set [Parameter(Mandatory=$true)] $object, - # ID of the ExportTemplate to set + # ID of the Site to set [Parameter()] [Int] $Id, @@ -3293,13 +3509,17 @@ Function Set-nbExportTemplate { [switch] $Patch ) - $Forward = @{ - Id = $id - Object = $object - CustomProperties = $CustomProperties - Lookup = $lookup - Patch = $patch - } - Set-nbObject -Resource 'extras/export-templates' @forward + try { + $Forward = @{ + Id = $id + Object = $object + CustomProperties = $CustomProperties + Lookup = $lookup + Patch = $patch + } + Set-nbObject -Resource 'dcim/sites' @forward + } catch { + $PSCmdlet.ThrowTerminatingError($_) + } } diff --git a/module/Version b/module/Version deleted file mode 100644 index cc6c9a4..0000000 --- a/module/Version +++ /dev/null @@ -1 +0,0 @@ -2.3.5 diff --git a/module/powerbox.psd1 b/module/powerbox.psd1 index 037982b..4912be7 100644 --- a/module/powerbox.psd1 +++ b/module/powerbox.psd1 @@ -12,7 +12,7 @@ RootModule = 'powerbox.psm1' # Version number of this module. - ModuleVersion = '2.3.5' + ModuleVersion = '2.4.4' # Supported PSEditions # CompatiblePSEditions = @() @@ -163,7 +163,7 @@ # ModuleList = @() # List of all files packaged with this module - FileList = 'powerbox.psd1', 'powerbox.psm1', 'Version', + FileList = 'powerbox.psd1', 'powerbox.psm1', 'Private\CreateCommands.ps1', 'Private\Get.txt', 'Private\New.txt', 'Private\ResourceMap.ps1', 'Private\Set.txt', 'Public\Connect-nbApi.ps1', 'Public\ConvertTo-nbId.ps1', diff --git a/test/nbx.tests.ps1 b/test/nbx.tests.ps1 index 0fb2d95..57bf307 100644 --- a/test/nbx.tests.ps1 +++ b/test/nbx.tests.ps1 @@ -4,13 +4,12 @@ Describe 'Set wrapper functions' { . $PSScriptRoot\ResourceMap.ps1 $testCases = $ResourceMap.Keys | - ForEach-Object { - @{ - function = "Set-nb$_" - resourcename = ($ResourceMap[$_]) - } + ForEach-Object { + @{ + function = "Set-nb$_" + resourcename = ($ResourceMap[$_]) } - + } it "should map to " -TestCases $testCases { param( $function, @@ -18,9 +17,10 @@ Describe 'Set wrapper functions' { ) #Mock -CommandName Invoke-nbApi -MockWith {} -ModuleName powerbox $filter = [scriptblock]::Create("`$Resource -eq '$resourceName'") - Mock -CommandName Set-NbObject -MockWith {} -ModuleName powerbox -Verifiable -ParameterFilter $filter - {&$function -Id 0 -object [pscustomobject]@{name='stuff'}} | should -Not -Throw - Assert-VerifiableMock + Mock -CommandName Set-NbObject -MockWith {} -ModuleName powerbox + { + &$function -Id 0 -object [pscustomobject]@ { name='stuff' } + } | should -Not -Throw -PassThru #| Should -Invoke -CommandName Set-NbObject -ModuleName powerbox -ParameterFilter $filter } } Describe 'New wrapper functions' { @@ -29,13 +29,12 @@ Describe 'New wrapper functions' { . $PSScriptRoot\ResourceMap.ps1 $testCases = $ResourceMap.Keys | - ForEach-Object { - @{ - function = "New-nb$_" - resourcename = ($ResourceMap[$_]) - } + ForEach-Object { + @{ + function = "New-nb$_" + resourcename = ($ResourceMap[$_]) } - + } it "should map to " -TestCases $testCases { param( $function, @@ -43,9 +42,10 @@ Describe 'New wrapper functions' { ) Mock -CommandName Invoke-nbApi -MockWith {} -ModuleName powerbox $filter = [scriptblock]::Create("`$Resource -eq '$resourceName'") - Mock -CommandName New-NbObject -MockWith {} -ModuleName powerbox -Verifiable -ParameterFilter $filter - {&$function -object [pscustomobject]@{name='stuff'}} | should -Not -Throw - Assert-VerifiableMock + Mock -CommandName New-NbObject -ModuleName powerbox -MockWith {} + { + &$function -object [pscustomobject]@ { name='stuff' } + } | should -Not -Throw -PassThru #| Should -Invoke -CommandName New-NbObject -ModuleName powerbox -ParameterFilter $filter } } Describe 'Get wrapper functions' { @@ -54,13 +54,12 @@ Describe 'Get wrapper functions' { . $PSScriptRoot\ResourceMap.ps1 $testCases = $ResourceMap.Keys | - ForEach-Object { - @{ - function = "Get-nb$_" - resourcename = ($ResourceMap[$_]) - } + ForEach-Object { + @{ + function = "Get-nb$_" + resourcename = ($ResourceMap[$_]) } - + } it "should map to " -TestCases $testCases { param( $function, @@ -68,9 +67,10 @@ Describe 'Get wrapper functions' { ) Mock -CommandName Invoke-nbApi -MockWith {} -ModuleName powerbox $filter = [scriptblock]::Create("`$Resource -eq '$resourceName'") - Mock -CommandName Get-NbObject -MockWith {} -ModuleName powerbox -Verifiable -ParameterFilter $filter - {&$function} | should -Not -Throw - Assert-VerifiableMock + Mock -CommandName Get-NbObject -MockWith {} -ModuleName powerbox + { + &$function + }| should -Not -Throw -PassThru #| should -Invoke -CommandName Get-NbObject -ModuleName powerbox -ParameterFilter $filter } it "should map -id 0 to /0" -TestCases $testCases { param( @@ -79,9 +79,10 @@ Describe 'Get wrapper functions' { ) Mock -CommandName Invoke-nbApi -MockWith {} -ModuleName powerbox $filter = [scriptblock]::Create("`$Resource -eq '$resourceName/0'") - Mock -CommandName Get-NbObject -MockWith {} -ModuleName powerbox -Verifiable -ParameterFilter $filter - {&$function -id 0} | should -Not -Throw - Assert-VerifiableMock + Mock -CommandName Get-NbObject -MockWith {} -ModuleName powerbox + { + &$function -id 0 + } | should -Not -Throw -PassThru #| Should -Invoke -CommandName Get-NbObject -ModuleName powerbox -ParameterFilter $filter } } Describe 'Remove wrapper functions' { @@ -90,12 +91,12 @@ Describe 'Remove wrapper functions' { . $PSScriptRoot\ResourceMap.ps1 $testCases = $ResourceMap.Keys | - ForEach-Object { - @{ - function = "Remove-nb$_" - resourcename = ($ResourceMap[$_]) - } + ForEach-Object { + @{ + function = "Remove-nb$_" + resourcename = ($ResourceMap[$_]) } + } it "should map to " -TestCases $testCases { param( $function, @@ -103,9 +104,10 @@ Describe 'Remove wrapper functions' { ) Mock -CommandName Invoke-nbApi -MockWith {} -ModuleName powerbox $filter = [scriptblock]::Create("`$Resource -eq '$resourceName' -and `$Id -eq '$id'") - Mock -CommandName Remove-NbObject -MockWith {} -ModuleName powerbox -Verifiable -ParameterFilter $filter - {&$function -id 0} | should -Not -Throw - Assert-VerifiableMock + Mock -CommandName Remove-NbObject -MockWith {} -ModuleName powerbox + { + &$function -id 0 + } | should -Not -Throw #| Should -Invoke -CommandName Remove-NbObject -ModuleName powerbox -ParameterFilter $filter } } diff --git a/test/new-nbobject.tests.ps1 b/test/new-nbobject.tests.ps1 index 31b604e..4aa20cf 100644 --- a/test/new-nbobject.tests.ps1 +++ b/test/new-nbobject.tests.ps1 @@ -11,12 +11,12 @@ Describe 'New object passes stuff through' { Mock Invoke-nbApi -MockWith {} -ModuleName powerbox -Verifiable {New-nbObject -Resource dcim/devices -Object $object} | should -not -Throw - #TODO: Submit bug report to pester on why this doesn't work with the parameter filter. - Assert-MockCalled -CommandName Invoke-nbApi -Times 1 -ModuleName powerbox <#-ParameterFilter { - $body -eq '{"Name":"NewDevice","Serial":"Example"}' -and + Assert-MockCalled -CommandName Invoke-nbApi -Times 1 -ModuleName powerbox -ParameterFilter { + $body -match '"name":"NewDevice"' -and + $body -match '"serial":"Example"' -and $resource -eq "dcim/devices" -and - $HttpVerb -eq 'POST' - }#> + $HttpVerb -eq [Microsoft.PowerShell.Commands.WebRequestMethod]::Post + } } it "Should passsthrough even with lookups" { $object = [pscustomobject]@{ @@ -27,14 +27,20 @@ Describe 'New object passes stuff through' { $lookup = @{ device_type = 'dcim/device-types' } - Mock Invoke-nbApi {} -ModuleName powerbox -Verifiable + Mock Invoke-nbApi {return 0} -ModuleName powerbox -Verifiable Mock ConvertTo-nbID {return 0} -ModuleName powerbox - {New-nbObject -Resource dcim/devices -Lookup $lookup -object $object } | Should -not -Throw - Assert-MockCalled -CommandName Invoke-nbApi -Times 2 -Exactly -ModuleName powerbox <#-ParameterFilter { - $body -eq '{"Name":"NewDevice","Serial":"Example","device-type":0}' -and + { + New-nbObject -Resource dcim/devices -Lookup $lookup -object $object + } | Should -not -Throw + Assert-MockCalled -CommandName Invoke-nbApi -Times 1 -Exactly -ModuleName powerbox -ParameterFilter { + #we can't guarantee the order in which the properties will be in the json, so we'll just make sure they exist in the json + $body -match '"device_type":0' -and + $body -match '"custom_fields":{}' -and + $body -match '"name":"NewDevice"' -and + $body -match '"serial":"Example"' -and $resource -eq 'dcim/devices' -and $HttpVerb -eq [Microsoft.PowerShell.Commands.WebRequestMethod]::Post - }#> - Assert-MockCalled -CommandName ConvertTo-nbID -Times 1 -Exactly -ModuleName powerbox + } + #Assert-MockCalled -CommandName ConvertTo-nbID -Times 1 -Exactly -ModuleName powerbox } } diff --git a/test/powerbox.Tests.ps1 b/test/powerbox.Tests.ps1 index 7c3e48a..017de35 100644 --- a/test/powerbox.Tests.ps1 +++ b/test/powerbox.Tests.ps1 @@ -1,14 +1,13 @@ -$moduleName = 'powerbox' -$manifestPath = "$PSScriptRoot\..\Release\$moduleName\*\$moduleName.psd1" - Describe 'module manifest values' { It 'can retrieve manfiest data' { + $moduleName = 'powerbox' + $manifestPath = "$PSScriptRoot\..\Release\$moduleName\*\$moduleName.psd1" $script:manifest = Test-ModuleManifest $manifestPath } It 'has the correct name' { - $script:manifest.Name | Should Be $moduleName + $script:manifest.Name | Should -Be $moduleName } It 'has the correct guid' { - $script:manifest.Guid | Should Be '1e8270f5-6b38-4cbb-b814-58ec2599da36' + $script:manifest.Guid | Should -Be '1e8270f5-6b38-4cbb-b814-58ec2599da36' } } diff --git a/test/remove-nbobject.tests.ps1 b/test/remove-nbobject.tests.ps1 index 9803f4a..07e86dd 100644 --- a/test/remove-nbobject.tests.ps1 +++ b/test/remove-nbobject.tests.ps1 @@ -4,11 +4,11 @@ Describe 'Remove object passes stuff through' { Connect-nbAPI -APIurl 'http://example.com' -Token $token } it "should call invoke-nbApi with the proper passthrough" { - $filter = [scriptblock]::Create("`$Resource -eq '$resourceName/0'") - #TODO: What the hell is up with mocking when I parameter validate? - #This errors if I uncomment the filter piece and it's because it actually reaches out to example.com.... Mock Invoke-nbApi -MockWith {} -ModuleName powerbox -Verifiable #-ParameterFilter $filter {Remove-nbObject -Id 0 -Resource dcim/devices} | should -not -Throw - Assert-VerifiableMock + Assert-MockCalled -CommandName Invoke-nbApi -Times 1 -ModuleName powerbox -ParameterFilter { + $resource -eq "dcim/devices/0" -and + $HttpVerb -eq [Microsoft.PowerShell.Commands.WebRequestMethod]::Delete + } } } diff --git a/test/set-nbobject.tests.ps1 b/test/set-nbobject.tests.ps1 index 3d0c55e..036be48 100644 --- a/test/set-nbobject.tests.ps1 +++ b/test/set-nbobject.tests.ps1 @@ -8,16 +8,14 @@ Describe 'Set object passes stuff through' { name = "NewDevice" serial = "Example" } - Mock Invoke-nbApi -MockWith {} -ModuleName powerbox -Verifiable {Set-nbObject -Id 1 -Resource dcim/devices -Object $object} | should -not -Throw - #TODO: Submit bug report to pester on why this doesn't work with the parameter filter. - Assert-MockCalled -CommandName Invoke-nbApi -Times 1 -ModuleName powerbox <#-ParameterFilter { - $Id -eq 1 -and - $body -eq '{"Name":"NewDevice","Serial":"Example"}' -and - $resource -eq "dcim/devices" -and - $HttpVerb -eq 'POST' - }#> + Assert-MockCalled -CommandName Invoke-nbApi -Times 1 -ModuleName powerbox -ParameterFilter { + $body -match '"name":"NewDevice"' -and + $body -match '"serial":"Example"' -and + $resource -eq "dcim/devices/1" -and + $HttpVerb -eq [Microsoft.PowerShell.Commands.WebRequestMethod]::Put + } } it "Should passsthrough even with lookups" { $object = [pscustomobject]@{ @@ -30,13 +28,16 @@ Describe 'Set object passes stuff through' { } Mock Invoke-nbApi {} -ModuleName powerbox -Verifiable Mock ConvertTo-nbID {return 0} -ModuleName powerbox - {Set-nbObject -Id 1 -Resource dcim/devices -Lookup $lookup -object $object } | Should -not -Throw - Assert-MockCalled -CommandName Invoke-nbApi -Times 2 -Exactly -ModuleName powerbox <#-ParameterFilter { - $Id -eq 1 -and - $body -eq '{"Name":"NewDevice","Serial":"Example","device-type":0}' -and - $resource -eq 'dcim/devices' -and - $HttpVerb -eq [Microsoft.PowerShell.Commands.WebRequestMethod]::Post - }#> - Assert-MockCalled -CommandName ConvertTo-nbID -Times 1 -Exactly -ModuleName powerbox + { + Set-nbObject -Id 1 -Resource dcim/devices -Lookup $lookup -object $object + } | Should -not -Throw + Assert-MockCalled -CommandName Invoke-nbApi -Times 1 -Exactly -ModuleName powerbox -ParameterFilter { + $body -match '"device_type":0' -and + $body -match '"name":"NewDevice"' -and + $body -match '"serial":"Example"' -and + $resource -eq 'dcim/devices/1' -and + $HttpVerb -eq [Microsoft.PowerShell.Commands.WebRequestMethod]::Put + } + #Assert-MockCalled -CommandName ConvertTo-nbID -Times 1 -Exactly -ModuleName powerbox } }