Skip to content

Remove-PowerAppRoleAssignment-Admin

PowerApps Admin: Removes an app role assignment

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

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

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

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

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

    [string]$ApiVersion
)

Process {
    try {
        ConnectPowerApps -PAFCredential $PACredential
        $cmdArgs = @{ ErrorAction = 'Stop'; AppName = $AppName; EnvironmentName = $EnvironmentName; RoleId = $RoleId }
        if ($PSBoundParameters.ContainsKey('ApiVersion')) { $cmdArgs.Add('ApiVersion', $ApiVersion) }
        $result = Remove-AdminPowerAppRoleAssignment @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 { DisconnectPowerApps }
}

PowerApps credentials for authentication

The role assignment ID to remove

The app identifier

The app's environment

API version to call

An interactive directory of PowerShell scripts.