Skip to content

Remove-AzDenyAssignment: -Confirm:$false ignored, always prompts (blocks automation) #29461

@jruttle

Description

@jruttle

Description

Remove-AzDenyAssignment always prompts for confirmation interactively, even when invoked with -Confirm:$false or with $ConfirmPreference = 'None' set in the session. This makes the cmdlet impossible to use in any non-interactive automation (CI pipelines, smoke tests, scheduled jobs, etc.).

The cmdlet is decorated with SupportsShouldProcess and ConfirmImpact = High (or equivalent), which should mean -Confirm:$false suppresses the prompt — but it does not.

Repro

Tested against the Debug build from PR #29340 (Az.Resources 9.0.3) in PowerShell 7 on Windows.

Import-Module C:\src\azure-powershell\artifacts\Debug\Az.Resources\Az.Resources.psd1 -Force
Connect-AzAccount -Tenant <tenant> -Subscription <sub>

$ConfirmPreference = 'None'
$da = New-AzDenyAssignment -Scope "/subscriptions/<sub>" -DenyAssignmentName "test" `
        -Description "test" -Action @("Microsoft.Storage/storageAccounts/delete") `
        -Principal @{ Id = "<user-oid>"; Type = "User" }

# This still prompts:
Remove-AzDenyAssignment -Id $da.Id -Confirm:$false
# Confirm
# Are you sure you want to remove deny assignment '...'? [Y] Yes  [N] No  ...

Expected

-Confirm:$false (and/or $ConfirmPreference = 'None') suppresses the prompt and the cmdlet performs the delete silently, matching standard SupportsShouldProcess behavior in every other Az cmdlet (e.g. Remove-AzRoleAssignment).

Actual

Prompt always appears regardless of -Confirm:$false, -Force, or $ConfirmPreference.

Impact

  • Blocks all automated testing of the new UADA delete path
  • Will block PowerShell GA — customers cannot script Remove-AzDenyAssignment

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions