Public/Remove-DuneTag.ps1

function Remove-DuneTag {
    [CmdletBinding(
        SupportsShouldProcess,
        ConfirmImpact = 'None'
    )]
    param (
        [Parameter(ValueFromPipeline, ParameterSetName = "Tenant")]
        [DuneTenant]$Tenant,

        [Parameter(ValueFromPipeline, ParameterSetName = "Deployment")]
        [DuneDeployment]$Deployment,

        [Parameter(ValueFromPipeline, ParameterSetName = "ResourceGroup")]
        [DuneResourceGroup]$ResourceGroup,

        [Parameter(ValueFromPipeline, ParameterSetName = "Resource")]
        [DuneResource]$Resource,

        [Parameter(Mandatory, Position = 0)]
        [String[]]$Name
    )

    begin {
        $Method = 'PATCH'
        if ($Name -is [Array] -and $Name.Count -gt 1) {
            $RemoveSingleTagParam = $PSBoundParameters
            $Name | ForEach-Object {
                $RemoveSingleTagParam.Name = $_
                Remove-DuneTag @RemoveSingleTagParam
            }
        }
    }

    process {
        Write-Debug "$($MyInvocation.MyCommand)|process|$($PSCmdlet.ParameterSetName)"
        switch ($PSCmdlet.ParameterSetName) {
            'Tenant' {
                $Uri = 'tenants/tags'
                $Tenant = Get-DuneTenant
                $Tags = $Tenant.Tags
            }
            'Deployment' {
                $Uri = 'deployments/{0}/tags' -f $Deployment.Id
                $Deployment = Get-DuneDeployment -Id $Deployment.Id
                $Tags = $Deployment.Tags
            }
            'ResourceGroup' {
                $Uri = 'resourcegroups/{0}/tags' -f $ResourceGroup.Id
                $ResourceGroup = Get-DuneResourceGroup -Id $ResourceGroup.Id
                $Tags = $ResourceGroup.Tags
            }
            'Resource' {
                $Uri = 'resources/{0}/tags' -f $Resource.Id
                $Resource = Get-DuneResource -Id $Resource.Id
                $Tags = $Resource.Tags
            }
            Default {
                return 'Type has no tags.'
            }
        }
        $Body = @{tags = @() }
        if ($Tags | Where-Object Name -NE $Name) { $Body.tags += ($Tags | Where-Object Name -NE $Name).ToPropertiesHashtable() }
        $Null = Invoke-DuneApiRequest -Uri $Uri -Method $Method -Body $Body
    }

    end {}
}