Public/Remove-OnePAMResource.ps1
|
function Remove-OnePAMResource { <# .SYNOPSIS Deletes a OnePAM resource. .DESCRIPTION Permanently removes a resource by its UUID. .PARAMETER Id The UUID of the resource to delete. .PARAMETER Force Skip confirmation prompt. .EXAMPLE Remove-OnePAMResource -Id "abc-123" .EXAMPLE Remove-OnePAMResource -Id "abc-123" -Force #> [CmdletBinding(SupportsShouldProcess)] param( [Parameter(Mandatory)] [string]$Id, [switch]$Force ) Assert-OpSafePathSegment -Value $Id -Label 'resource ID' if (-not $Force -and -not $PSCmdlet.ShouldProcess($Id, 'Delete resource')) { return } $encoded = [System.Uri]::EscapeDataString($Id) Invoke-OpApiRaw -Method DELETE -Path "/api/v1/resources/$encoded" | Out-Null Write-Host "Resource $Id deleted." -ForegroundColor Green } |