Skip to content

Deny-FlowApprovalRequest

PowerApps: Rejects a flow approval request

#Requires -Version 5.1
#Requires -Modules Microsoft.PowerApps.PowerShell

[CmdletBinding()]
Param(
    [Parameter(Mandatory = $true)]
    [pscredential]$PACredential,

    [Parameter(Mandatory = $true)]
    [string]$ApprovalId,

    [Parameter(Mandatory = $true)]
    [string]$ApprovalRequestId,

    [Parameter(Mandatory = $true)]
    [string]$EnvironmentName,

    [Parameter(Mandatory = $true)]
    [string]$Comments,

    [string]$ApiVersion
)

Process {
    try {
        ConnectPowerApps4Creators -PAFCredential $PACredential

        $cmdArgs = @{
            ErrorAction         = 'Stop'
            EnvironmentName     = $EnvironmentName
            ApprovalRequestId   = $ApprovalRequestId
            ApprovalId          = $ApprovalId
            Comments            = $Comments
        }

        if ($PSBoundParameters.ContainsKey('ApiVersion')) {
            $cmdArgs.Add('ApiVersion', $ApiVersion)
        }

        $result = Deny-FlowApprovalRequest @cmdArgs -ErrorAction Stop | Select-Object *

        if ($null -ne $result) {
            $result | Add-Member -NotePropertyName Timestamp -NotePropertyValue (Get-Date -Format "yyyy-MM-dd HH:mm:ss") -PassThru -Force
        }
    }
    catch { throw }
    finally { DisconnectPowerApps4Creators }
}

PowerApps credentials for authentication

ID of the approval to respond to

ID of the user's request for the approval

Environment containing the approval

Comments to attach to the response

API version to call

An interactive directory of PowerShell scripts.