Set-ConnectorRoleAssignment
PowerApps: Sets a connector role assignment
#Requires -Version 5.1
#Requires -Modules Microsoft.PowerApps.PowerShell
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[pscredential]$PACredential,
[Parameter(Mandatory = $true)]
[string]$PrincipalObjectId,
[Parameter(Mandatory = $true)]
[ValidateSet('CanView', 'CanEdit')]
[string]$RoleName,
[string]$ConnectorName,
[string]$EnvironmentName,
[string]$ApiVersion
)
Process {
try {
ConnectPowerApps4Creators -PAFCredential $PACredential
$args = @{ ErrorAction = 'Stop'; PrincipalObjectId = $PrincipalObjectId; RoleName = $RoleName }
if ($PSBoundParameters.ContainsKey('ConnectorName')) { $args.Add('ConnectorName', $ConnectorName) }
if ($PSBoundParameters.ContainsKey('EnvironmentName')) { $args.Add('EnvironmentName', $EnvironmentName) }
if ($PSBoundParameters.ContainsKey('ApiVersion')) { $args.Add('ApiVersion', $ApiVersion) }
$result = Set-AdminPowerAppConnectorRoleAssignment @args -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
Principal object ID to assign
Role to assign: CanView, CanEdit
The connector identifier
The connector's environment
API version to call