From c5fcb6e970a802275fbe2bbb3621e01055210d03 Mon Sep 17 00:00:00 2001 From: Alexis La Goutte Date: Wed, 28 Jul 2021 22:10:39 +0200 Subject: [PATCH] Site(DCIM): Add Remove-NetboxDCIMSite for Remove DCIM Site --- .../DCIM/Sites/Remove-NetboxDCIMSite.ps1 | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 Functions/DCIM/Sites/Remove-NetboxDCIMSite.ps1 diff --git a/Functions/DCIM/Sites/Remove-NetboxDCIMSite.ps1 b/Functions/DCIM/Sites/Remove-NetboxDCIMSite.ps1 new file mode 100644 index 0000000..a87737c --- /dev/null +++ b/Functions/DCIM/Sites/Remove-NetboxDCIMSite.ps1 @@ -0,0 +1,64 @@ +<# + .NOTES + =========================================================================== + Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.181 + Created on: 2020-10-02 15:52 + Created by: Claussen + Organization: NEOnet + Filename: New-NetboxDCIMSite.ps1 + =========================================================================== + .DESCRIPTION + A description of the file. +#> + + +function Remove-NetboxDCIMSite { + <# + .SYNOPSIS + Remove a Site + + .DESCRIPTION + Remove a DCIM Site from Netbox + + .EXAMPLE + Remove-NetboxDCIMSite -Id 1 + + Remove DCM Site with id 1 + + .EXAMPLE + Get-NetboxDCIMSite -name My Site | Remove-NetboxDCIMSite -confirm:$false + + Remove DCM Site with name My Site without confirmation + + #> + + [CmdletBinding(ConfirmImpact = 'High', + SupportsShouldProcess = $true)] + param + ( + [Parameter(Mandatory = $true, + ValueFromPipelineByPropertyName = $true)] + [uint]$Id + + ) + + begin { + + } + + process { + $CurrentSite = Get-NetboxDCIMSite -Id $Id -ErrorAction Stop + + if ($pscmdlet.ShouldProcess("$($CurrentSite.Name)/$($CurrentSite.Id)", "Remove Site")) { + $Segments = [System.Collections.ArrayList]::new(@('dcim', 'sites', $CurrentSite.Id)) + + $URI = BuildNewURI -Segments $Segments + + InvokeNetboxRequest -URI $URI -Method DELETE + } + } + + end { + + } +} \ No newline at end of file