Skip to content

Remove-ConnectorRoleAssignment-Admin

PowerApps Admin: Removes a connector role assignment

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

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

    [string]$ConnectorName,
    [string]$PrincipalObjectId,
    [string]$EnvironmentName,
    [string]$ApiVersion
)

Process {
    try {
        ConnectPowerApps -PAFCredential $PACredential
        $args = @{ ErrorAction = 'Stop' }
        if ($PSBoundParameters.ContainsKey('ConnectorName')) { $args.Add('ConnectorName', $ConnectorName) }
        if ($PSBoundParameters.ContainsKey('PrincipalObjectId')) { $args.Add('PrincipalObjectId', $PrincipalObjectId) }
        if ($PSBoundParameters.ContainsKey('EnvironmentName')) { $args.Add('EnvironmentName', $EnvironmentName) }
        if ($PSBoundParameters.ContainsKey('ApiVersion')) { $args.Add('ApiVersion', $ApiVersion) }
        Remove-AdminPowerAppConnectorRoleAssignment @args -ErrorAction Stop
        [PSCustomObject]@{ Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"; Status = "Success"; Message = "Connector role assignment removed" }
    }
    catch { throw }
    finally { DisconnectPowerApps }
}

PowerApps credentials

The connector identifier

The assignee to remove

The connector's environment

API version to call

An interactive directory of PowerShell scripts.