Merge branch 'add-virtualdisk'

This commit is contained in:
Pascal Liehne 2024-09-01 21:02:02 +02:00
commit 73c472e273
4 changed files with 141 additions and 26 deletions

View file

@ -0,0 +1,55 @@

function Remove-NetboxVirtualMachineDisk {
<#
.SYNOPSIS
Delete a virtual machine disk
.DESCRIPTION
Deletes a virtual machine disk from Netbox by ID
.PARAMETER Id
Database ID of the virtual machine disk
.PARAMETER Force
Force deletion without any prompts
.EXAMPLE
PS C:\> Remove-NetboxVirtualMachineDisk -Id $value1
.NOTES
Additional information about the function.
#>
[CmdletBinding(ConfirmImpact = 'High',
SupportsShouldProcess = $true)]
param
(
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true)]
[uint64[]]$Id,
[switch]$Force
)
begin {
}
process {
foreach ($DiskId in $Id) {
$CurrentDisk = Get-NetboxVirtualMachineDisk -Id $DiskId -ErrorAction Stop
if ($Force -or $pscmdlet.ShouldProcess("$($CurrentDisk.Name)/$($CurrentDisk.Id)", "Remove")) {
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-disks', $CurrentDisk.Id))
$URI = BuildNewURI -Segments $Segments
InvokeNetboxRequest -URI $URI -Method DELETE
}
}
}
end {
}
}

View file

@ -105,19 +105,19 @@ FunctionsToExport = 'Add-NetboxDCIMFrontPort', 'Add-NetboxDCIMInterface',
'Remove-NetboxDCIMInterfaceConnection', 'Remove-NetboxDCIMRearPort', 'Remove-NetboxDCIMInterfaceConnection', 'Remove-NetboxDCIMRearPort',
'Remove-NetboxDCIMSite', 'Remove-NetboxIPAMAddress', 'Remove-NetboxDCIMSite', 'Remove-NetboxIPAMAddress',
'Remove-NetboxIPAMAddressRange', 'Remove-NetboxVirtualMachine', 'Remove-NetboxIPAMAddressRange', 'Remove-NetboxVirtualMachine',
'Set-NetboxCipherSSL', 'Set-NetboxContact', 'Remove-NetboxVirtualMachinedisk', 'Set-NetboxCipherSSL',
'Set-NetboxContactAssignment', 'Set-NetboxContactRole', 'Set-NetboxContact', 'Set-NetboxContactAssignment',
'Set-NetboxCredential', 'Set-NetboxDCIMDevice', 'Set-NetboxContactRole', 'Set-NetboxCredential',
'Set-NetboxDCIMFrontPort', 'Set-NetboxDCIMInterface', 'Set-NetboxDCIMDevice', 'Set-NetboxDCIMFrontPort',
'Set-NetboxDCIMInterfaceConnection', 'Set-NetboxDCIMRearPort', 'Set-NetboxDCIMInterface', 'Set-NetboxDCIMInterfaceConnection',
'Set-NetboxHostName', 'Set-NetboxHostPort', 'Set-NetboxHostScheme', 'Set-NetboxDCIMRearPort', 'Set-NetboxHostName', 'Set-NetboxHostPort',
'Set-NetboxInvokeParams', 'Set-NetboxIPAMAddress', 'Set-NetboxHostScheme', 'Set-NetboxInvokeParams',
'Set-NetboxIPAMAddressRange', 'Set-NetboxIPAMPrefix', 'Set-NetboxIPAMAddress', 'Set-NetboxIPAMAddressRange',
'Set-NetboxTimeout', 'Set-NetboxUnstrustedSSL', 'Set-NetboxIPAMPrefix', 'Set-NetboxTimeout',
'Set-NetboxVirtualMachine', 'Set-NetboxVirtualMachinedisk', 'Set-NetboxUnstrustedSSL', 'Set-NetboxVirtualMachine',
'Set-NetboxVirtualMachineInterface', 'SetupNetboxConfigVariable', 'Set-NetboxVirtualMachinedisk', 'Set-NetboxVirtualMachineInterface',
'Test-NetboxAPIConnected', 'ThrowNetboxRESTError', 'SetupNetboxConfigVariable', 'Test-NetboxAPIConnected',
'VerifyAPIConnectivity' 'ThrowNetboxRESTError', 'VerifyAPIConnectivity'
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @() CmdletsToExport = @()

View file

@ -105,19 +105,19 @@ FunctionsToExport = 'Add-NetboxDCIMFrontPort', 'Add-NetboxDCIMInterface',
'Remove-NetboxDCIMInterfaceConnection', 'Remove-NetboxDCIMRearPort', 'Remove-NetboxDCIMInterfaceConnection', 'Remove-NetboxDCIMRearPort',
'Remove-NetboxDCIMSite', 'Remove-NetboxIPAMAddress', 'Remove-NetboxDCIMSite', 'Remove-NetboxIPAMAddress',
'Remove-NetboxIPAMAddressRange', 'Remove-NetboxVirtualMachine', 'Remove-NetboxIPAMAddressRange', 'Remove-NetboxVirtualMachine',
'Set-NetboxCipherSSL', 'Set-NetboxContact', 'Remove-NetboxVirtualMachinedisk', 'Set-NetboxCipherSSL',
'Set-NetboxContactAssignment', 'Set-NetboxContactRole', 'Set-NetboxContact', 'Set-NetboxContactAssignment',
'Set-NetboxCredential', 'Set-NetboxDCIMDevice', 'Set-NetboxContactRole', 'Set-NetboxCredential',
'Set-NetboxDCIMFrontPort', 'Set-NetboxDCIMInterface', 'Set-NetboxDCIMDevice', 'Set-NetboxDCIMFrontPort',
'Set-NetboxDCIMInterfaceConnection', 'Set-NetboxDCIMRearPort', 'Set-NetboxDCIMInterface', 'Set-NetboxDCIMInterfaceConnection',
'Set-NetboxHostName', 'Set-NetboxHostPort', 'Set-NetboxHostScheme', 'Set-NetboxDCIMRearPort', 'Set-NetboxHostName', 'Set-NetboxHostPort',
'Set-NetboxInvokeParams', 'Set-NetboxIPAMAddress', 'Set-NetboxHostScheme', 'Set-NetboxInvokeParams',
'Set-NetboxIPAMAddressRange', 'Set-NetboxIPAMPrefix', 'Set-NetboxIPAMAddress', 'Set-NetboxIPAMAddressRange',
'Set-NetboxTimeout', 'Set-NetboxUnstrustedSSL', 'Set-NetboxIPAMPrefix', 'Set-NetboxTimeout',
'Set-NetboxVirtualMachine', 'Set-NetboxVirtualMachinedisk', 'Set-NetboxUnstrustedSSL', 'Set-NetboxVirtualMachine',
'Set-NetboxVirtualMachineInterface', 'SetupNetboxConfigVariable', 'Set-NetboxVirtualMachinedisk', 'Set-NetboxVirtualMachineInterface',
'Test-NetboxAPIConnected', 'ThrowNetboxRESTError', 'SetupNetboxConfigVariable', 'Test-NetboxAPIConnected',
'VerifyAPIConnectivity' 'ThrowNetboxRESTError', 'VerifyAPIConnectivity'
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @() CmdletsToExport = @()

View file

@ -5148,6 +5148,66 @@ function Remove-NetboxVirtualMachine {
#endregion #endregion
#region File Remove-NetboxVirtualMachinedisk.ps1
function Remove-NetboxVirtualMachineDisk {
<#
.SYNOPSIS
Delete a virtual machine disk
.DESCRIPTION
Deletes a virtual machine disk from Netbox by ID
.PARAMETER Id
Database ID of the virtual machine disk
.PARAMETER Force
Force deletion without any prompts
.EXAMPLE
PS C:\> Remove-NetboxVirtualMachineDisk -Id $value1
.NOTES
Additional information about the function.
#>
[CmdletBinding(ConfirmImpact = 'High',
SupportsShouldProcess = $true)]
param
(
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true)]
[uint64[]]$Id,
[switch]$Force
)
begin {
}
process {
foreach ($DiskId in $Id) {
$CurrentDisk = Get-NetboxVirtualMachineDisk -Id $DiskId -ErrorAction Stop
if ($Force -or $pscmdlet.ShouldProcess("$($CurrentDisk.Name)/$($CurrentDisk.Id)", "Remove")) {
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-disks', $CurrentDisk.Id))
$URI = BuildNewURI -Segments $Segments
InvokeNetboxRequest -URI $URI -Method DELETE
}
}
}
end {
}
}
#endregion
#region File Set-NetboxCipherSSL.ps1 #region File Set-NetboxCipherSSL.ps1
Function Set-NetboxCipherSSL { Function Set-NetboxCipherSSL {